mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-11-22 09:46:58 +01:00
Add few tests
This commit is contained in:
parent
5e2c3c90cd
commit
a5efa38121
7
.babelrc
7
.babelrc
@ -1,5 +1,10 @@
|
|||||||
{
|
{
|
||||||
"presets": ["es2015-no-commonjs"],
|
"presets": [
|
||||||
|
"@ava/stage-4",
|
||||||
|
"@ava/transform-test-files",
|
||||||
|
"es2015-no-commonjs"
|
||||||
|
],
|
||||||
|
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"transform-export-extensions",
|
"transform-export-extensions",
|
||||||
"transform-object-assign",
|
"transform-object-assign",
|
||||||
|
20
package.json
20
package.json
@ -71,5 +71,23 @@
|
|||||||
"blockchain",
|
"blockchain",
|
||||||
"decentralized",
|
"decentralized",
|
||||||
"dapp"
|
"dapp"
|
||||||
]
|
],
|
||||||
|
"ava": {
|
||||||
|
"files": [
|
||||||
|
"test/*.js"
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"**/*.{js,jsx}",
|
||||||
|
"!node_modules/**/*",
|
||||||
|
"!dist/**/*"
|
||||||
|
],
|
||||||
|
"failFast": true,
|
||||||
|
"failWithoutAssertions": false,
|
||||||
|
"tap": true,
|
||||||
|
"powerAssert": false,
|
||||||
|
"require": [
|
||||||
|
"babel-register"
|
||||||
|
],
|
||||||
|
"babel": "inherit"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
export default function makeOutput(condition, amount = 1) {
|
export default function makeOutput(condition, amount = 1) {
|
||||||
return {
|
return {
|
||||||
'amount': amount.toString(),
|
'amount': amount,
|
||||||
condition,
|
condition,
|
||||||
'public_keys': condition.details.hasOwnProperty('public_key') ?
|
'public_keys': condition.details.hasOwnProperty('public_key') ?
|
||||||
[condition.details.public_key] : [],
|
[condition.details.public_key] : [],
|
||||||
|
29
test/test.js
29
test/test.js
@ -1,11 +1,30 @@
|
|||||||
import test from 'ava'
|
import test from 'ava'
|
||||||
|
import { Ed25519Keypair, Transaction, Connection } from '../src'
|
||||||
|
|
||||||
test('foo', t => {
|
const API_PATH = 'http://localhost:9984/api/v1/'
|
||||||
t.pass()
|
|
||||||
|
test('Keypair is created', t => {
|
||||||
|
const keyPair = new Ed25519Keypair()
|
||||||
|
|
||||||
|
t.truthy(keyPair.publicKey)
|
||||||
|
t.truthy(keyPair.privateKey)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('bar', async t => {
|
test('Valid CREATE transaction is evaluated by BigchainDB', t => {
|
||||||
const bar = Promise.resolve('bar')
|
const alice = new Ed25519Keypair()
|
||||||
|
const asset = { name: 'Shmui', type: 'cat' }
|
||||||
|
const metadata = { dayOfTheWeek: 'Caturday' }
|
||||||
|
|
||||||
t.is(await bar, 'bar')
|
const tx = Transaction.makeCreateTransaction(
|
||||||
|
asset,
|
||||||
|
metadata,
|
||||||
|
[Transaction.makeOutput(Transaction.makeEd25519Condition(alice.publicKey))],
|
||||||
|
alice.publicKey
|
||||||
|
)
|
||||||
|
|
||||||
|
const txSigned = Transaction.signTransaction(tx, alice.privateKey)
|
||||||
|
const conn = new Connection(API_PATH)
|
||||||
|
return conn.postTransaction(txSigned)
|
||||||
|
.then(resTx => t.truthy(resTx))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user