From 70681a3085de6f31758ba5083b84f74d20aa93ed Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Thu, 22 Jun 2017 16:13:59 +0200 Subject: [PATCH] tests for cryptoconditions --- .../test_cryptoconditions.js} | 35 ++----------------- 1 file changed, 3 insertions(+), 32 deletions(-) rename test/{test2.js => transaction/test_cryptoconditions.js} (69%) diff --git a/test/test2.js b/test/transaction/test_cryptoconditions.js similarity index 69% rename from test/test2.js rename to test/transaction/test_cryptoconditions.js index 230bdcd..a60b87c 100644 --- a/test/test2.js +++ b/test/transaction/test_cryptoconditions.js @@ -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(