mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
remove use of random in test_bigchain_api
This commit is contained in:
parent
6c31ab0a7c
commit
7c4c7e9be3
@ -1,7 +1,6 @@
|
|||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import random
|
|
||||||
|
|
||||||
pytestmark = pytest.mark.bdb
|
pytestmark = pytest.mark.bdb
|
||||||
|
|
||||||
@ -155,14 +154,14 @@ class TestBigchainApi(object):
|
|||||||
|
|
||||||
monkeypatch.setattr('time.time', lambda: 1000000000)
|
monkeypatch.setattr('time.time', lambda: 1000000000)
|
||||||
tx1 = Transaction.create([b.me], [([b.me], 1)],
|
tx1 = Transaction.create([b.me], [([b.me], 1)],
|
||||||
metadata={'msg': random.random()})
|
metadata={'msg': 1})
|
||||||
tx1 = tx1.sign([b.me_private])
|
tx1 = tx1.sign([b.me_private])
|
||||||
block1 = b.create_block([tx1])
|
block1 = b.create_block([tx1])
|
||||||
b.write_block(block1)
|
b.write_block(block1)
|
||||||
|
|
||||||
monkeypatch.setattr('time.time', lambda: 1000000020)
|
monkeypatch.setattr('time.time', lambda: 1000000020)
|
||||||
tx2 = Transaction.create([b.me], [([b.me], 1)],
|
tx2 = Transaction.create([b.me], [([b.me], 1)],
|
||||||
metadata={'msg': random.random()})
|
metadata={'msg': 2})
|
||||||
tx2 = tx2.sign([b.me_private])
|
tx2 = tx2.sign([b.me_private])
|
||||||
block2 = b.create_block([tx2])
|
block2 = b.create_block([tx2])
|
||||||
b.write_block(block2)
|
b.write_block(block2)
|
||||||
@ -510,13 +509,13 @@ class TestBigchainApi(object):
|
|||||||
b.nodes_except_me.append(generate_key_pair()[1])
|
b.nodes_except_me.append(generate_key_pair()[1])
|
||||||
|
|
||||||
# test assignee for several transactions
|
# test assignee for several transactions
|
||||||
for _ in range(20):
|
for i in range(20):
|
||||||
input_tx = b.get_owned_ids(user_pk).pop()
|
input_tx = b.get_owned_ids(user_pk).pop()
|
||||||
input_tx = b.get_transaction(input_tx.txid)
|
input_tx = b.get_transaction(input_tx.txid)
|
||||||
inputs = input_tx.to_inputs()
|
inputs = input_tx.to_inputs()
|
||||||
tx = Transaction.transfer(inputs, [([user_pk], 1)],
|
tx = Transaction.transfer(inputs, [([user_pk], 1)],
|
||||||
asset_id=input_tx.id,
|
asset_id=input_tx.id,
|
||||||
metadata={'msg': random.random()})
|
metadata={'msg': i})
|
||||||
tx = tx.sign([user_sk])
|
tx = tx.sign([user_sk])
|
||||||
b.write_transaction(tx)
|
b.write_transaction(tx)
|
||||||
|
|
||||||
@ -549,9 +548,9 @@ class TestBigchainApi(object):
|
|||||||
from bigchaindb.backend import query
|
from bigchaindb.backend import query
|
||||||
from bigchaindb.models import Transaction
|
from bigchaindb.models import Transaction
|
||||||
|
|
||||||
for _ in range(4):
|
for i in range(4):
|
||||||
tx = Transaction.create([b.me], [([user_pk], 1)],
|
tx = Transaction.create([b.me], [([user_pk], 1)],
|
||||||
metadata={'msg': random.random()}) \
|
metadata={'msg': i}) \
|
||||||
.sign([b.me_private])
|
.sign([b.me_private])
|
||||||
b.write_transaction(tx)
|
b.write_transaction(tx)
|
||||||
|
|
||||||
@ -1129,7 +1128,7 @@ class TestMultipleInputs(object):
|
|||||||
|
|
||||||
transactions = []
|
transactions = []
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
payload = {'somedata': random.randint(0, 255)}
|
payload = {'somedata': i}
|
||||||
tx = Transaction.create([b.me], [([user_pk, user2_pk], 1)],
|
tx = Transaction.create([b.me], [([user_pk, user2_pk], 1)],
|
||||||
payload)
|
payload)
|
||||||
tx = tx.sign([b.me_private])
|
tx = tx.sign([b.me_private])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user