mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Problem: test_get_spent_issue_1271 was marked to skip
Solution: Merge the changes from master that fix this test, and remove the skip
This commit is contained in:
commit
4cf4d3316d
@ -18,6 +18,14 @@ For reference, the possible headings are:
|
|||||||
* **Known Issues**
|
* **Known Issues**
|
||||||
* **Notes**
|
* **Notes**
|
||||||
|
|
||||||
|
## [2.0 Beta 3] - 2018-07-18
|
||||||
|
|
||||||
|
Tag name: v2.0.0b3
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
Fixed a bug in transaction validation. For some more-complex situations, it would say that a valid transaction was invalid. This bug was actually fixed before; it was [issue #1271](https://github.com/bigchaindb/bigchaindb/issues/1271). The unit test for it was turned off while we integrated Tendermint. Then the query implementation code got changed, reintroducing the bug, but the unit test was off so the bug wasn't caught. When we turned the test back on, shortly after releasing Beta 2, it failed, unveiling the bug. [Pull request #2389](https://github.com/bigchaindb/bigchaindb/pull/2389)
|
||||||
|
|
||||||
## [2.0 Beta 2] - 2018-07-16
|
## [2.0 Beta 2] - 2018-07-16
|
||||||
|
|
||||||
Tag name: v2.0.0b2
|
Tag name: v2.0.0b2
|
||||||
|
|||||||
@ -99,11 +99,13 @@ def get_assets(conn, asset_ids):
|
|||||||
|
|
||||||
@register_query(LocalMongoDBConnection)
|
@register_query(LocalMongoDBConnection)
|
||||||
def get_spent(conn, transaction_id, output):
|
def get_spent(conn, transaction_id, output):
|
||||||
|
query = {'inputs.fulfills': {
|
||||||
|
'transaction_id': transaction_id,
|
||||||
|
'output_index': output}}
|
||||||
|
|
||||||
return conn.run(
|
return conn.run(
|
||||||
conn.collection('transactions')
|
conn.collection('transactions')
|
||||||
.find({'inputs.fulfills.transaction_id': transaction_id,
|
.find(query, {'_id': 0}))
|
||||||
'inputs.fulfills.output_index': output},
|
|
||||||
{'_id': 0}))
|
|
||||||
|
|
||||||
|
|
||||||
@register_query(LocalMongoDBConnection)
|
@register_query(LocalMongoDBConnection)
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
__version__ = '2.0.0b2'
|
__version__ = '2.0.0b3'
|
||||||
__short_version__ = '2.0b2'
|
__short_version__ = '2.0b3'
|
||||||
|
|||||||
@ -1,7 +1,14 @@
|
|||||||
# Write a BigchaindB Enhancement Proposal (BEP)
|
# Write a BigchainDB Enhancement Proposal (BEP)
|
||||||
|
|
||||||
- Review [1/C4](https://github.com/bigchaindb/BEPs/tree/master/1), the process we use to accept any new code or PR of any kind, including one that adds a BEP to `bigchaindb/BEPs`.
|
If you have an idea for a new feature or enhancement, and you want some feedback before you write a full BigchainDB Enhancement Proposal (BEP), then feel free to:
|
||||||
- Review [2/COSS](https://github.com/bigchaindb/BEPs/tree/master/2). Maybe print it for reference. It outlines what can go in a BEP.
|
- ask in the [bigchaindb/bigchaindb Gitter chat room](https://gitter.im/bigchaindb/bigchaindb) or
|
||||||
- Don't spend weeks on your BEP. Version 1 should take up to a few hours to write. You can add to it in the future. The process is iterative. If you need more than a few hours, then consider writing multiple BEPs.
|
- [open a new issue in the bigchaindb/BEPs repo](https://github.com/bigchaindb/BEPs/issues/new) and give it the label **BEP idea**.
|
||||||
- Do _not_ start writing code before you think about it. You should always write a BEP first. Once you do that, you can start implementing it. To do that, make a pull request and say it implements your BEP.
|
|
||||||
- Do _not_ write your BEP as an issue (i.e. a GitHub issue).
|
If you want to discuss an existing BEP, then [open a new issue in the bigchaindb/BEPs repo](https://github.com/bigchaindb/BEPs/issues/new) and give it the label **discuss existing BEP**.
|
||||||
|
|
||||||
|
## Steps to Write a New BEP
|
||||||
|
|
||||||
|
1. Look at the structure of existing BEPs in the [bigchaindb/BEPs repo](https://github.com/bigchaindb/BEPs). Note the section headings. [BEP-2](https://github.com/bigchaindb/BEPs/tree/master/2) (our variant of the consensus-oriented specification system [COSS]) says more about the expected structure and process.
|
||||||
|
1. Write a first draft of your BEP. It doesn't have to be long or perfect.
|
||||||
|
1. Push your BEP draft to the [bigchaindb/BEPs repo](https://github.com/bigchaindb/BEPs) and make a pull request. [BEP-1](https://github.com/bigchaindb/BEPs/tree/master/1) (our variant of C4) outlines the process we use to handle all pull requests. In particular, we try to merge all pull requests quickly.
|
||||||
|
1. Your BEP can be revised by pushing more pull requests.
|
||||||
|
|||||||
@ -52,10 +52,11 @@ BigchainDB Server requires **Python 3.6+**, so make sure your system has it. Ins
|
|||||||
sudo apt install -y python3-pip libssl-dev
|
sudo apt install -y python3-pip libssl-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
Now install the latest version of BigchainDB. Check the [project page on PyPI][bdb:pypi] for the last version (which was `2.0.0a6` at the time of writing) and install it:
|
Now install the latest version of BigchainDB. You can find the latest version by going to the [BigchainDB project release history page on PyPI][bdb:pypi]. For example, to install version 2.0.0b3, you would do:
|
||||||
|
|
||||||
```
|
```
|
||||||
sudo pip3 install bigchaindb==2.0.0a6
|
# Change 2.0.0b3 to the latest version as explained above:
|
||||||
|
sudo pip3 install bigchaindb==2.0.0b3
|
||||||
```
|
```
|
||||||
|
|
||||||
Check that you installed the correct version of BigchainDB Server using `bigchaindb --version`.
|
Check that you installed the correct version of BigchainDB Server using `bigchaindb --version`.
|
||||||
|
|||||||
@ -154,7 +154,7 @@ spec:
|
|||||||
timeoutSeconds: 15
|
timeoutSeconds: 15
|
||||||
# BigchainDB container
|
# BigchainDB container
|
||||||
- name: bigchaindb
|
- name: bigchaindb
|
||||||
image: bigchaindb/bigchaindb:2.0.0-beta2
|
image: bigchaindb/bigchaindb:2.0.0-beta3
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
args:
|
args:
|
||||||
- start
|
- start
|
||||||
|
|||||||
@ -34,7 +34,7 @@ spec:
|
|||||||
terminationGracePeriodSeconds: 10
|
terminationGracePeriodSeconds: 10
|
||||||
containers:
|
containers:
|
||||||
- name: bigchaindb
|
- name: bigchaindb
|
||||||
image: bigchaindb/bigchaindb:2.0.0-beta2
|
image: bigchaindb/bigchaindb:2.0.0-beta3
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
args:
|
args:
|
||||||
- start
|
- start
|
||||||
|
|||||||
@ -3,6 +3,10 @@ import pytest
|
|||||||
pytestmark = [pytest.mark.tendermint, pytest.mark.bdb]
|
pytestmark = [pytest.mark.tendermint, pytest.mark.bdb]
|
||||||
|
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.tendermint
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(reason='will be fixed in another PR')
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def config(request, monkeypatch):
|
def config(request, monkeypatch):
|
||||||
backend = request.config.getoption('--database-backend')
|
backend = request.config.getoption('--database-backend')
|
||||||
@ -31,6 +35,7 @@ def config(request, monkeypatch):
|
|||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(reason='will be fixed in another PR')
|
||||||
def test_bigchain_class_default_initialization(config):
|
def test_bigchain_class_default_initialization(config):
|
||||||
from bigchaindb.tendermint import BigchainDB
|
from bigchaindb.tendermint import BigchainDB
|
||||||
from bigchaindb.consensus import BaseConsensusRules
|
from bigchaindb.consensus import BaseConsensusRules
|
||||||
@ -62,7 +67,19 @@ def test_bigchain_class_initialization_with_parameters():
|
|||||||
assert bigchain.consensus == BaseConsensusRules
|
assert bigchain.consensus == BaseConsensusRules
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
def test_get_blocks_status_containing_tx(monkeypatch):
|
||||||
|
from bigchaindb.backend import query as backend_query
|
||||||
|
from bigchaindb.tendermint import BigchainDB
|
||||||
|
blocks = [
|
||||||
|
{'id': 1}, {'id': 2}
|
||||||
|
]
|
||||||
|
monkeypatch.setattr(backend_query, 'get_blocks_status_from_transaction', lambda x: blocks)
|
||||||
|
monkeypatch.setattr(BigchainDB, 'block_election_status', lambda x, y, z: BigchainDB.BLOCK_VALID)
|
||||||
|
bigchain = BigchainDB(public_key='pubkey', private_key='privkey')
|
||||||
|
with pytest.raises(Exception):
|
||||||
|
bigchain.get_blocks_status_containing_tx('txid')
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.genesis
|
@pytest.mark.genesis
|
||||||
def test_get_spent_issue_1271(b, alice, bob, carol):
|
def test_get_spent_issue_1271(b, alice, bob, carol):
|
||||||
from bigchaindb.models import Transaction
|
from bigchaindb.models import Transaction
|
||||||
@ -71,6 +88,8 @@ def test_get_spent_issue_1271(b, alice, bob, carol):
|
|||||||
[carol.public_key],
|
[carol.public_key],
|
||||||
[([carol.public_key], 8)],
|
[([carol.public_key], 8)],
|
||||||
).sign([carol.private_key])
|
).sign([carol.private_key])
|
||||||
|
assert b.validate_transaction(tx_1)
|
||||||
|
b.store_bulk_transactions([tx_1])
|
||||||
|
|
||||||
tx_2 = Transaction.transfer(
|
tx_2 = Transaction.transfer(
|
||||||
tx_1.to_inputs(),
|
tx_1.to_inputs(),
|
||||||
@ -79,6 +98,8 @@ def test_get_spent_issue_1271(b, alice, bob, carol):
|
|||||||
([carol.public_key], 4)],
|
([carol.public_key], 4)],
|
||||||
asset_id=tx_1.id,
|
asset_id=tx_1.id,
|
||||||
).sign([carol.private_key])
|
).sign([carol.private_key])
|
||||||
|
assert b.validate_transaction(tx_2)
|
||||||
|
b.store_bulk_transactions([tx_2])
|
||||||
|
|
||||||
tx_3 = Transaction.transfer(
|
tx_3 = Transaction.transfer(
|
||||||
tx_2.to_inputs()[2:3],
|
tx_2.to_inputs()[2:3],
|
||||||
@ -86,20 +107,25 @@ def test_get_spent_issue_1271(b, alice, bob, carol):
|
|||||||
([carol.public_key], 3)],
|
([carol.public_key], 3)],
|
||||||
asset_id=tx_1.id,
|
asset_id=tx_1.id,
|
||||||
).sign([carol.private_key])
|
).sign([carol.private_key])
|
||||||
|
assert b.validate_transaction(tx_3)
|
||||||
|
b.store_bulk_transactions([tx_3])
|
||||||
|
|
||||||
tx_4 = Transaction.transfer(
|
tx_4 = Transaction.transfer(
|
||||||
tx_2.to_inputs()[1:2] + tx_3.to_inputs()[0:1],
|
tx_2.to_inputs()[1:2] + tx_3.to_inputs()[0:1],
|
||||||
[([bob.public_key], 3)],
|
[([bob.public_key], 3)],
|
||||||
asset_id=tx_1.id,
|
asset_id=tx_1.id,
|
||||||
).sign([alice.private_key])
|
).sign([alice.private_key])
|
||||||
|
assert b.validate_transaction(tx_4)
|
||||||
|
b.store_bulk_transactions([tx_4])
|
||||||
|
|
||||||
tx_5 = Transaction.transfer(
|
tx_5 = Transaction.transfer(
|
||||||
tx_2.to_inputs()[0:1],
|
tx_2.to_inputs()[0:1],
|
||||||
[([alice.public_key], 2)],
|
[([alice.public_key], 2)],
|
||||||
asset_id=tx_1.id,
|
asset_id=tx_1.id,
|
||||||
).sign([bob.private_key])
|
).sign([bob.private_key])
|
||||||
block_5 = b.create_block([tx_1, tx_2, tx_3, tx_4, tx_5])
|
assert b.validate_transaction(tx_5)
|
||||||
b.write_block(block_5)
|
b.store_bulk_transactions([tx_5])
|
||||||
|
|
||||||
assert b.get_spent(tx_2.id, 0) == tx_5
|
assert b.get_spent(tx_2.id, 0) == tx_5
|
||||||
assert not b.get_spent(tx_5.id, 0)
|
assert not b.get_spent(tx_5.id, 0)
|
||||||
assert b.get_outputs_filtered(alice.public_key)
|
assert b.get_outputs_filtered(alice.public_key)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user