mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-11-22 01:36:56 +01:00
Add few tests
This commit is contained in:
parent
5e2c3c90cd
commit
a5efa38121
9
.babelrc
9
.babelrc
@ -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 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
20
package.json
20
package.json
@ -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"
|
||||
}
|
||||
}
|
||||
|
@ -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] : [],
|
||||
|
29
test/test.js
29
test/test.js
@ -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))
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user