From f5cd60e63de6d3a87c17629f3cb013ffbcb0c9a9 Mon Sep 17 00:00:00 2001 From: getlarge Date: Tue, 9 Mar 2021 13:49:06 +0100 Subject: [PATCH] fix: update test constants --- test/constants.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/test/constants.js b/test/constants.js index b1708e9..a85c63b 100644 --- a/test/constants.js +++ b/test/constants.js @@ -2,8 +2,8 @@ // SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) // Code is Apache-2.0 and docs are CC-BY-4.0 -import test from 'ava' import base58 from 'bs58' +import { createHash } from 'crypto' import { Ed25519Sha256 } from 'crypto-conditions' import { Transaction, Ed25519Keypair } from '../src' // TODO: Find out if ava has something like conftest, if so put this there. @@ -34,20 +34,19 @@ export const bobCondition = Transaction.makeEd25519Condition(bob.publicKey) export const bobOutput = Transaction.makeOutput(bobCondition) export function delegatedSignTransaction(...keyPairs) { - return function sign(input, transactionHash) { + return function sign(serializedTransaction, input, index) { + const transactionUniqueFulfillment = input.fulfills ? serializedTransaction + .concat(input.fulfills.transaction_id) + .concat(input.fulfills.output_index) : serializedTransaction + const transactionHash = createHash('sha3-256').update(transactionUniqueFulfillment).digest() const filteredKeyPairs = keyPairs.filter(({ publicKey }) => input.owners_before.includes(publicKey)) + const ed25519Fulfillment = new Ed25519Sha256() filteredKeyPairs.forEach(keyPair => { const privateKey = Buffer.from(base58.decode(keyPair.privateKey)) - ed25519Fulfillment.sign( - Buffer.from(transactionHash, 'hex'), - privateKey - ) + ed25519Fulfillment.sign(transactionHash, privateKey) }) return ed25519Fulfillment.serializeUri() } } - -// TODO: https://github.com/avajs/ava/issues/1190 -test('', () => 'dirty hack. TODO: Exclude this file from being run by ava')