const crypto = require('crypto')
const tape = require('tape')
const DfinityTx = require('../')
tape('tests', async t => {
const tx = new DfinityTx({
version: 0,
to: new Uint8Array(20),
caps: 0,
ticks: 0,
ticksPrice: 0,
nonce: 0,
height: 0,
data: new Uint8Array([])
})
const sk = crypto.randomBytes(32)
const signedTx = await tx.sign(sk)
const result = await DfinityTx.validateSignature(signedTx)
t.equals(result !== false, true, 'should validate message')
// console.log(tx2)
try {
const tx2 = await DfinityTx.deserialize(signedTx)
t.deepEquals(tx2.serialize(), signedTx)
} catch (e) {
console.log(e)
}
t.end()
})
|