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:
parent
8bd602f446
commit
3671c5758c
@ -67,7 +67,7 @@ export default class Connection {
|
|||||||
* @param transactionId
|
* @param transactionId
|
||||||
* @param status
|
* @param status
|
||||||
*/
|
*/
|
||||||
listBlocks({ transactionId, status }) {
|
listBlocks(transactionId, status) {
|
||||||
return this._req(this.getApiUrls('blocks'), {
|
return this._req(this.getApiUrls('blocks'), {
|
||||||
query: {
|
query: {
|
||||||
transaction_id: transactionId,
|
transaction_id: transactionId,
|
||||||
|
@ -97,7 +97,7 @@ test('Get list of blocks for a transaction id', t => {
|
|||||||
conn._req = sinon.spy()
|
conn._req = sinon.spy()
|
||||||
conn.getApiUrls = sinon.stub().returns(expectedPath)
|
conn.getApiUrls = sinon.stub().returns(expectedPath)
|
||||||
|
|
||||||
conn.listBlocks({ transactionId, status })
|
conn.listBlocks(transactionId, status)
|
||||||
t.truthy(conn._req.calledWith(
|
t.truthy(conn._req.calledWith(
|
||||||
expectedPath,
|
expectedPath,
|
||||||
{
|
{
|
||||||
|
@ -269,3 +269,28 @@ test('Search for an asset', t => {
|
|||||||
createTxSigned.asset.data.message
|
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))
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user