mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-11-22 01:36:56 +01:00
refactor code & add test
This commit is contained in:
parent
d812e64b30
commit
34c82a1ae8
@ -119,10 +119,7 @@ export default class Connection {
|
||||
* @param transaction
|
||||
*/
|
||||
postTransaction(transaction) {
|
||||
return this._req(this.getApiUrls('transactionsCommit'), {
|
||||
method: 'POST',
|
||||
jsonBody: transaction
|
||||
})
|
||||
return this.postTransactionCommit(transaction)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,6 +27,9 @@ test('Generate API URLS', t => {
|
||||
'blocksDetail': 'blocks/%(blockHeight)s',
|
||||
'outputs': 'outputs',
|
||||
'transactions': 'transactions',
|
||||
'transactionsSync': 'transactions?mode=sync',
|
||||
'transactionsAsync': 'transactions?mode=async',
|
||||
'transactionsCommit': 'transactions?mode=commit',
|
||||
'transactionsDetail': 'transactions/%(transactionId)s',
|
||||
'assets': 'assets',
|
||||
}
|
||||
|
@ -35,7 +35,39 @@ test('Valid CREATE transaction', t => {
|
||||
)
|
||||
const txSigned = Transaction.signTransaction(tx, alice.privateKey)
|
||||
|
||||
return conn.postTransactionCommit(txSigned)
|
||||
return conn.postTransaction(txSigned)
|
||||
.then(resTx => t.truthy(resTx))
|
||||
})
|
||||
|
||||
|
||||
test('Valid CREATE transaction using async', t => {
|
||||
const conn = new Connection(API_PATH)
|
||||
|
||||
const tx = Transaction.makeCreateTransaction(
|
||||
asset(),
|
||||
metaData,
|
||||
[aliceOutput],
|
||||
alice.publicKey
|
||||
)
|
||||
const txSigned = Transaction.signTransaction(tx, alice.privateKey)
|
||||
|
||||
return conn.postTransactionAsync(txSigned)
|
||||
.then(resTx => t.truthy(resTx))
|
||||
})
|
||||
|
||||
|
||||
test('Valid CREATE transaction using sync', t => {
|
||||
const conn = new Connection(API_PATH)
|
||||
|
||||
const tx = Transaction.makeCreateTransaction(
|
||||
asset(),
|
||||
metaData,
|
||||
[aliceOutput],
|
||||
alice.publicKey
|
||||
)
|
||||
const txSigned = Transaction.signTransaction(tx, alice.privateKey)
|
||||
|
||||
return conn.postTransactionSync(txSigned)
|
||||
.then(resTx => t.truthy(resTx))
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user