diff --git a/src/connection/index.js b/src/connection/index.js index 64afc6a..a4dafc6 100644 --- a/src/connection/index.js +++ b/src/connection/index.js @@ -98,14 +98,13 @@ export default class Connection { /** * @public - * @param asset_id + * @param assetId * @param operation */ - // TODO: Use camel case for parameters - listTransactions({ asset_id, operation }) { + listTransactions(assetId, operation) { return this._req(this.getApiUrls('transactions'), { query: { - asset_id, + asset_id: assetId, operation } }) diff --git a/test/connection/test_connection.js b/test/connection/test_connection.js index 6b90186..af398c5 100644 --- a/test/connection/test_connection.js +++ b/test/connection/test_connection.js @@ -59,7 +59,7 @@ test('Get block for a block id', t => { }) -test('Get status for a transaction', t => { +test('Get status for a transaction id', t => { const expectedPath = 'path' const transactionId = 'abc' @@ -110,6 +110,27 @@ test('Get list of blocks for a transaction id', t => { }) +test('Get list of transactions for an asset id', t => { + const expectedPath = 'path' + const assetId = 'abc' + const operation = 'operation' + + conn._req = sinon.spy() + conn.getApiUrls = sinon.stub().returns(expectedPath) + + conn.listTransactions(assetId, operation) + t.truthy(conn._req.calledWith( + expectedPath, + { + query: { + asset_id: assetId, + operation + } + } + )) +}) + + test('Get outputs for a public key and no spent flag', t => { const expectedPath = 'path' const publicKey = 'publicKey' diff --git a/test/integration/test_integration.js b/test/integration/test_integration.js index 7199722..5b1d184 100644 --- a/test/integration/test_integration.js +++ b/test/integration/test_integration.js @@ -294,3 +294,24 @@ test('Search blocks containing a transaction', t => { )) .then(transactions => t.truthy(transactions.length === 1)) }) + + +test('Search transaction containing an asset', 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, 'CREATE')) + .then(({ id }) => conn.listTransactions(id)) + .then(transactions => t.truthy(transactions.length === 1)) +})