mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-11-22 09:46:58 +01:00
search metadata field
This commit is contained in:
parent
5f2ee8c0d8
commit
dd2a52bf1f
@ -25,6 +25,7 @@ export default class Connection {
|
||||
'transactions': 'transactions',
|
||||
'transactionsDetail': 'transactions/%(transactionId)s',
|
||||
'assets': 'assets',
|
||||
'metadata': 'metadata',
|
||||
'votes': 'votes'
|
||||
}[endpoint]
|
||||
}
|
||||
@ -167,7 +168,6 @@ export default class Connection {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @public
|
||||
* @param search
|
||||
@ -179,4 +179,16 @@ export default class Connection {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
* @param search
|
||||
*/
|
||||
searchMetadata(search) {
|
||||
return this._req(this.getApiUrls('metadata'), {
|
||||
query: {
|
||||
search
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -219,3 +219,18 @@ test('Get asset for text', t => {
|
||||
{ query: { search } }
|
||||
))
|
||||
})
|
||||
|
||||
|
||||
test('Get metadata for text', t => {
|
||||
const expectedPath = 'path'
|
||||
const search = 'abc'
|
||||
|
||||
conn._req = sinon.spy()
|
||||
conn.getApiUrls = sinon.stub().returns(expectedPath)
|
||||
|
||||
conn.searchMetadata(search)
|
||||
t.truthy(conn._req.calledWith(
|
||||
expectedPath,
|
||||
{ query: { search } }
|
||||
))
|
||||
})
|
||||
|
@ -264,6 +264,29 @@ test('Search for an asset', t => {
|
||||
})
|
||||
|
||||
|
||||
test('Search for metadata', 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(() => conn.searchMetadata(createTxSigned.metadata.message))
|
||||
.then(assets => t.truthy(
|
||||
assets.pop(),
|
||||
createTxSigned.metadata.message
|
||||
))
|
||||
})
|
||||
|
||||
test('Search blocks containing a transaction', t => {
|
||||
const conn = new Connection(API_PATH)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user