1
0
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:
vrde 2017-06-16 11:22:23 +02:00
parent 5e2c3c90cd
commit a5efa38121
No known key found for this signature in database
GPG Key ID: 6581C7C39B3D397D
4 changed files with 51 additions and 9 deletions

View File

@ -1,5 +1,10 @@
{
"presets": ["es2015-no-commonjs"],
"presets": [
"@ava/stage-4",
"@ava/transform-test-files",
"es2015-no-commonjs"
],
"plugins": [
"transform-export-extensions",
"transform-object-assign",
@ -23,4 +28,4 @@
]
}
}
}
}

View File

@ -71,5 +71,23 @@
"blockchain",
"decentralized",
"dapp"
]
],
"ava": {
"files": [
"test/*.js"
],
"source": [
"**/*.{js,jsx}",
"!node_modules/**/*",
"!dist/**/*"
],
"failFast": true,
"failWithoutAssertions": false,
"tap": true,
"powerAssert": false,
"require": [
"babel-register"
],
"babel": "inherit"
}
}

View File

@ -8,7 +8,7 @@
*/
export default function makeOutput(condition, amount = 1) {
return {
'amount': amount.toString(),
'amount': amount,
condition,
'public_keys': condition.details.hasOwnProperty('public_key') ?
[condition.details.public_key] : [],

View File

@ -1,11 +1,30 @@
import test from 'ava'
import { Ed25519Keypair, Transaction, Connection } from '../src'
test('foo', t => {
t.pass()
const API_PATH = 'http://localhost:9984/api/v1/'
test('Keypair is created', t => {
const keyPair = new Ed25519Keypair()
t.truthy(keyPair.publicKey)
t.truthy(keyPair.privateKey)
})
test('bar', async t => {
const bar = Promise.resolve('bar')
test('Valid CREATE transaction is evaluated by BigchainDB', t => {
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))
})