@aeternity/aepp-sdk
Version:
SDK for the æternity blockchain
59 lines (50 loc) • 2.06 kB
JavaScript
/*
* ISC License (ISC)
* Copyright (c) 2018 aeternity developers
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
import { describe, it, before } from 'mocha'
import { configure, ready } from './'
import { generateKeyPair } from '../../es/utils/crypto'
describe('Node Chain', function () {
configure(this)
let client
const { publicKey } = generateKeyPair()
before(async function () {
client = await ready(this)
})
it('determines the height', async () => {
return client.height().should.eventually.be.a('number')
})
it('waits for specified heights', async () => {
const target = await client.height() + 1
await client.awaitHeight(target, { attempts: 120 }).should.eventually.be.at.least(target)
return client.height().should.eventually.be.at.least(target)
})
it('polls for transactions', async () => {
const sender = await client.address()
const receiver = publicKey
const tx = await client.spendTx({
amount: 1,
senderId: sender,
recipientId: receiver,
payload: '',
ttl: Number.MAX_SAFE_INTEGER
})
const signed = await client.signTransaction(tx)
const { txHash } = await client.api.postTransaction({ tx: signed })
await client.poll(txHash).should.eventually.be.fulfilled
return client.poll('th_xxx', { blocks: 1 }).should.eventually.be.rejected
})
})