mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-12-28 15:47:50 +01:00
tests for cryptoconditions
This commit is contained in:
parent
e19a37fb78
commit
70681a3085
@ -1,38 +1,7 @@
|
||||
import test from 'ava'
|
||||
import cc from 'five-bells-condition'
|
||||
import { Ed25519Keypair, Transaction, Connection } from '../src'
|
||||
import { Ed25519Keypair, Transaction } from '../../src'
|
||||
|
||||
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('Valid CREATE transaction is evaluated by BigchainDB', t => {
|
||||
const alice = new Ed25519Keypair()
|
||||
const asset = { name: 'Shmui', type: 'cat' }
|
||||
const metadata = { dayOfTheWeek: 'Caturday' }
|
||||
|
||||
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))
|
||||
})
|
||||
|
||||
|
||||
/*
|
||||
* CryptoConditions support tests
|
||||
*/
|
||||
|
||||
test('Ed25519 condition encoding', t => {
|
||||
const publicKey = '4zvwRjXUKGfvwnParsHAS3HuSVzV5cA4McphgmoCtajS'
|
||||
@ -47,6 +16,7 @@ test('Ed25519 condition encoding', t => {
|
||||
t.deepEqual(target, Transaction.makeEd25519Condition(publicKey))
|
||||
})
|
||||
|
||||
|
||||
test('Threshold condition encoding', t => {
|
||||
const publicKey = '4zvwRjXUKGfvwnParsHAS3HuSVzV5cA4McphgmoCtajS'
|
||||
const condition = Transaction.makeThresholdCondition(
|
||||
@ -66,6 +36,7 @@ test('Threshold condition encoding', t => {
|
||||
t.deepEqual(target, condition)
|
||||
})
|
||||
|
||||
|
||||
test('Fulfillment correctly formed', t => {
|
||||
const alice = new Ed25519Keypair()
|
||||
const txCreate = Transaction.makeCreateTransaction(
|
Loading…
Reference in New Issue
Block a user