1
0
mirror of https://github.com/bigchaindb/js-bigchaindb-driver.git synced 2025-02-14 21:10:32 +01:00

Test list blocks for a transaction id

This commit is contained in:
tim 2017-06-21 11:00:51 +02:00
parent 8bd602f446
commit 3671c5758c
3 changed files with 27 additions and 2 deletions

View File

@ -67,7 +67,7 @@ export default class Connection {
* @param transactionId
* @param status
*/
listBlocks({ transactionId, status }) {
listBlocks(transactionId, status) {
return this._req(this.getApiUrls('blocks'), {
query: {
transaction_id: transactionId,

View File

@ -97,7 +97,7 @@ test('Get list of blocks for a transaction id', t => {
conn._req = sinon.spy()
conn.getApiUrls = sinon.stub().returns(expectedPath)
conn.listBlocks({ transactionId, status })
conn.listBlocks(transactionId, status)
t.truthy(conn._req.calledWith(
expectedPath,
{

View File

@ -269,3 +269,28 @@ test('Search for an asset', t => {
createTxSigned.asset.data.message
))
})
test('Search blocks containing a transaction', t => {
const conn = new Connection(API_PATH)
const createTx = Transaction.makeCreateTransaction(
asset(),
metaData,
[aliceOutput],
alice.publicKey
)
const createTxSigned = Transaction.signTransaction(
createTx,
alice.privateKey
)
return conn.postTransaction(createTxSigned)
.then(({ id }) => conn.pollStatusAndFetchTransaction(id))
.then(({ id }) => conn.listBlocks(id, 'VALID'))
.then(blocks => conn.getBlock(blocks.pop()))
.then(({ block: { transactions } }) => transactions.filter(
({ id }) => id === createTxSigned.id
))
.then(transactions => t.truthy(transactions.length === 1))
})