2018-08-10 12:49:26 +02:00
|
|
|
// Copyright BigchainDB GmbH and BigchainDB contributors
|
|
|
|
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
|
|
|
// Code is Apache-2.0 and docs are CC-BY-4.0
|
|
|
|
|
2017-06-19 17:50:09 +02:00
|
|
|
import test from 'ava'
|
|
|
|
import { Transaction, Ed25519Keypair } from '../src'
|
|
|
|
// TODO: Find out if ava has something like conftest, if so put this there.
|
|
|
|
|
2017-06-21 16:23:53 +02:00
|
|
|
// NOTE: It's safer to cast `Math.random()` to a string, to avoid differences
|
|
|
|
// in "float interpretation" between languages (e.g. JavaScript and Python)
|
2018-03-26 12:15:36 +02:00
|
|
|
export const API_PATH = 'http://localhost:9984/api/v1/'
|
2017-06-20 16:17:43 +02:00
|
|
|
export function asset() { return { message: `${Math.random()}` } }
|
|
|
|
export const metaData = { message: 'metaDataMessage' }
|
2017-06-19 17:50:09 +02:00
|
|
|
|
|
|
|
export const alice = new Ed25519Keypair()
|
|
|
|
export const aliceCondition = Transaction.makeEd25519Condition(alice.publicKey)
|
|
|
|
export const aliceOutput = Transaction.makeOutput(aliceCondition)
|
|
|
|
export const createTx = Transaction.makeCreateTransaction(
|
2017-06-20 16:17:43 +02:00
|
|
|
asset,
|
|
|
|
metaData,
|
2017-06-19 17:50:09 +02:00
|
|
|
[aliceOutput],
|
|
|
|
alice.publicKey
|
|
|
|
)
|
|
|
|
export const transferTx = Transaction.makeTransferTransaction(
|
2017-09-19 21:47:33 +02:00
|
|
|
[{ tx: createTx, output_index: 0 }],
|
2017-06-19 17:50:09 +02:00
|
|
|
[aliceOutput],
|
2017-09-19 21:47:33 +02:00
|
|
|
metaData
|
2017-06-19 17:50:09 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
export const bob = new Ed25519Keypair()
|
|
|
|
export const bobCondition = Transaction.makeEd25519Condition(bob.publicKey)
|
|
|
|
export const bobOutput = Transaction.makeOutput(bobCondition)
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: https://github.com/avajs/ava/issues/1190
|
|
|
|
test('', () => 'dirty hack. TODO: Exclude this file from being run by ava')
|