mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-11-22 01:36:56 +01:00
test integration failing
This commit is contained in:
parent
2451ed2ae6
commit
abe1c89025
@ -20,6 +20,7 @@
|
||||
"build:dist": "cross-env NODE_ENV=production webpack -p",
|
||||
"clean": "rimraf dist/bundle dist/node",
|
||||
"test": "npm run lint && nyc ava test/ && npm run thanks && npm run report-coverage",
|
||||
"testmine": "npm run lint && nyc ava test/integration/test_min*",
|
||||
"thanks": "cowsay Hi, thanks for your interest in BigchainDB. We appreciate your contribution!",
|
||||
"release": "./node_modules/release-it/bin/release-it.js --src.tagName='v%s' --github.release --npm.publish --non-interactive",
|
||||
"release-minor": "./node_modules/release-it/bin/release-it.js minor --src.tagName='v%s' --github.release --npm.publish --non-interactive",
|
||||
|
@ -3,8 +3,8 @@ import sinon from 'sinon'
|
||||
|
||||
import * as request from '../../src/request' // eslint-disable-line
|
||||
import { Connection } from '../../src'
|
||||
import { API_PATH } from '../constants'
|
||||
|
||||
const API_PATH = 'http://localhost:9984/api/v1/'
|
||||
const conn = new Connection(API_PATH)
|
||||
|
||||
test('Payload thrown at incorrect API_PATH', t => {
|
||||
|
@ -4,6 +4,7 @@ import { Transaction, Ed25519Keypair } from '../src'
|
||||
|
||||
// NOTE: It's safer to cast `Math.random()` to a string, to avoid differences
|
||||
// in "float interpretation" between languages (e.g. JavaScript and Python)
|
||||
export const API_PATH = 'http://localhost:9984/api/v1/'
|
||||
export function asset() { return { message: `${Math.random()}` } }
|
||||
export const metaData = { message: 'metaDataMessage' }
|
||||
|
||||
|
@ -2,6 +2,7 @@ import test from 'ava'
|
||||
import { Ed25519Keypair, Transaction, Connection } from '../../src'
|
||||
|
||||
import {
|
||||
API_PATH,
|
||||
alice,
|
||||
aliceCondition,
|
||||
aliceOutput,
|
||||
@ -11,8 +12,6 @@ import {
|
||||
metaData
|
||||
} from '../constants'
|
||||
|
||||
const API_PATH = 'http://localhost:9984/api/v1/'
|
||||
|
||||
|
||||
test('Keypair is created', t => {
|
||||
const keyPair = new Ed25519Keypair()
|
||||
@ -36,7 +35,7 @@ test('Valid CREATE transaction', t => {
|
||||
)
|
||||
const txSigned = Transaction.signTransaction(tx, alice.privateKey)
|
||||
|
||||
return conn.postTransactionSync(txSigned)
|
||||
return conn.postTransactionCommit(txSigned)
|
||||
.then(resTx => t.truthy(resTx))
|
||||
})
|
||||
|
||||
@ -199,7 +198,7 @@ test('Search for spent and unspent outputs of a given public key', t => {
|
||||
carol.privateKey,
|
||||
)
|
||||
|
||||
return conn.postTransactionSync(createTxSigned)
|
||||
return conn.postTransactionCommit(createTxSigned)
|
||||
.then(() => conn.postTransactionSync(transferTxSigned))
|
||||
.then(() => conn.listOutputs(carol.publicKey))
|
||||
// now listOutputs should return us outputs 0 and 1 (unfiltered)
|
||||
@ -239,7 +238,7 @@ test('Search for unspent outputs for a given public key', t => {
|
||||
carol.privateKey,
|
||||
)
|
||||
|
||||
return conn.postTransactionSync(createTxSigned)
|
||||
return conn.postTransactionCommit(createTxSigned)
|
||||
.then(() => conn.postTransactionSync(transferTxSigned))
|
||||
// now listOutputs should return us outputs 0 and 2 (1 is spent)
|
||||
.then(() => conn.listOutputs(carol.publicKey, 'false'))
|
||||
@ -279,7 +278,7 @@ test('Search for spent outputs for a given public key', t => {
|
||||
carol.privateKey,
|
||||
)
|
||||
|
||||
return conn.postTransactionSync(createTxSigned)
|
||||
return conn.postTransactionCommit(createTxSigned)
|
||||
.then(() => conn.postTransactionSync(transferTxSigned))
|
||||
// now listOutputs should only return us output 1 (0 and 2 are unspent)
|
||||
.then(() => conn.listOutputs(carol.publicKey, true))
|
||||
@ -301,10 +300,10 @@ test('Search for an asset', t => {
|
||||
alice.privateKey
|
||||
)
|
||||
|
||||
return conn.postTransactionSync(createTxSigned)
|
||||
return conn.postTransactionCommit(createTxSigned)
|
||||
.then(() => conn.searchAssets(createTxSigned.asset.data.message))
|
||||
.then(assets => t.truthy(
|
||||
console.log('llllllllllllllllllll', createTxSigned.asset.data.message, assets.pop()),
|
||||
console.log('llllllllllllllllllll', createTxSigned.asset.data.message, assets),
|
||||
assets.pop(),
|
||||
createTxSigned.asset.data.message
|
||||
))
|
||||
@ -325,7 +324,7 @@ test('Search for metadata', t => {
|
||||
alice.privateKey
|
||||
)
|
||||
|
||||
return conn.postTransactionSync(createTxSigned)
|
||||
return conn.postTransactionCommit(createTxSigned)
|
||||
.then(() => conn.searchMetadata(createTxSigned.metadata.message))
|
||||
.then(assets => t.truthy(
|
||||
assets.pop(),
|
||||
@ -348,10 +347,16 @@ test('Search blocks containing a transaction', t => {
|
||||
alice.privateKey
|
||||
)
|
||||
|
||||
return conn.postTransactionSync(createTxSigned)
|
||||
.then(({ id }) => conn.listBlocks(id))
|
||||
.then(blocks => conn.getBlock(blocks.pop()))
|
||||
.then(({ block: { transactions } }) => transactions.filter(({ id }) => id === createTxSigned.id))
|
||||
return conn.postTransactionCommit(createTxSigned)
|
||||
.then(({ id }) => {
|
||||
console.log('hhhhhhhhhh', id)
|
||||
return conn.listBlocks(id)
|
||||
})
|
||||
.then(blockHeight => {
|
||||
console.log('wwwwwwww', blockHeight)
|
||||
conn.getBlock(blockHeight.pop())
|
||||
})
|
||||
.then(({ transactions }) => transactions.filter(({ id }) => id === createTxSigned.id))
|
||||
.then(transactions => t.truthy(transactions.length === 1))
|
||||
})
|
||||
|
||||
@ -370,7 +375,7 @@ test('Search transaction containing an asset', t => {
|
||||
alice.privateKey
|
||||
)
|
||||
|
||||
return conn.postTransactionSync(createTxSigned)
|
||||
return conn.postTransactionCommit(createTxSigned)
|
||||
.then(({ id }) => conn.listTransactions(id))
|
||||
.then(transactions => {
|
||||
console.log('cccccccccccc', transactions, createTxSigned.id)
|
||||
|
64
test/integration/test_mine.js
Normal file
64
test/integration/test_mine.js
Normal file
@ -0,0 +1,64 @@
|
||||
import test from 'ava'
|
||||
import { Transaction, Connection } from '../../src'
|
||||
|
||||
import {
|
||||
API_PATH,
|
||||
alice,
|
||||
aliceOutput,
|
||||
asset,
|
||||
metaData
|
||||
} from '../constants'
|
||||
|
||||
|
||||
test('Search transaction containing an asset', t => {
|
||||
const conn = new Connection(API_PATH)
|
||||
|
||||
console.log('posting')
|
||||
const createTx = Transaction.makeCreateTransaction(
|
||||
asset(),
|
||||
metaData,
|
||||
[aliceOutput],
|
||||
alice.publicKey
|
||||
)
|
||||
const createTxSigned = Transaction.signTransaction(
|
||||
createTx,
|
||||
alice.privateKey
|
||||
)
|
||||
console.log('the payload is ', JSON.stringify(createTxSigned), { showHidden: false, depth: null })
|
||||
|
||||
return conn.postTransactionCommit(createTxSigned)
|
||||
.then(({ id }) => conn.listTransactions(id))
|
||||
.then(transactions => {
|
||||
console.log('cccccccccccc', transactions, createTxSigned.id)
|
||||
t.truthy(transactions.length === 1)
|
||||
})
|
||||
})
|
||||
|
||||
test('Valid TRANSFER transaction with single Ed25519 input', t => {
|
||||
const conn = new Connection(API_PATH)
|
||||
const createTx = Transaction.makeCreateTransaction(
|
||||
asset(),
|
||||
metaData,
|
||||
[aliceOutput],
|
||||
alice.publicKey
|
||||
)
|
||||
const createTxSigned = Transaction.signTransaction(
|
||||
createTx,
|
||||
alice.privateKey
|
||||
)
|
||||
|
||||
return conn.postTransactionSync(createTxSigned)
|
||||
.then(() => {
|
||||
const transferTx = Transaction.makeTransferTransaction(
|
||||
[{ tx: createTxSigned, output_index: 0 }],
|
||||
[aliceOutput],
|
||||
metaData
|
||||
)
|
||||
const transferTxSigned = Transaction.signTransaction(
|
||||
transferTx,
|
||||
alice.privateKey
|
||||
)
|
||||
return conn.postTransactionSync(transferTxSigned)
|
||||
.then(resTx => t.truthy(resTx))
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user