From: Chris Duncan Date: Mon, 25 Nov 2024 16:54:37 +0000 (-0800) Subject: Substitute hard-coded test vector block values for constants. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=a8d7a59486e8981f17b52a25134649e7e73eea5c;p=libnemo.git Substitute hard-coded test vector block values for constants. --- diff --git a/test/sign-blocks.test.mjs b/test/sign-blocks.test.mjs index c539e00..05058d5 100644 --- a/test/sign-blocks.test.mjs +++ b/test/sign-blocks.test.mjs @@ -63,62 +63,58 @@ describe('valid blocks', async () => { describe('block signing tests using official test vectors', async () => { it('should create a valid signature for a receive block', async () => { - const work = 'c5cf86de24b24419' const block = new ReceiveBlock( - 'nano_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx', - '18618869000000000000000000000000', - 'CBC911F57B6827649423C92C88C0C56637A4274FF019E77E24D61D12B5338783', - '7000000000000000000000000000000', - 'nano_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou', - '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D', - work + NANO_TEST_VECTORS.RECEIVE_BLOCK.account, + NANO_TEST_VECTORS.RECEIVE_BLOCK.balance, + NANO_TEST_VECTORS.RECEIVE_BLOCK.link, + '0', + NANO_TEST_VECTORS.RECEIVE_BLOCK.representative, + NANO_TEST_VECTORS.RECEIVE_BLOCK.previous, + NANO_TEST_VECTORS.RECEIVE_BLOCK.work ) - await block.sign('781186FB9EF17DB6E3D1056550D9FAE5D5BBADA6A6BC370E4CBB938B1DC71DA3') - assert.equal(block.signature, 'F25D751AD0379A5718E08F3773DA6061A9E18842EF5615163C7F207B804CC2C5DD2720CFCE5FE6A78E4CC108DD9CAB65051526403FA2C24A1ED943BB4EA7880B') - assert.equal(block.work, work) + await block.sign(NANO_TEST_VECTORS.RECEIVE_BLOCK.key) + assert.equal(block.signature, NANO_TEST_VECTORS.RECEIVE_BLOCK.signature) }) it('should create a valid signature for a receive block without work', async () => { const block = new ReceiveBlock( - 'nano_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx', - '18618869000000000000000000000000', - 'CBC911F57B6827649423C92C88C0C56637A4274FF019E77E24D61D12B5338783', - '7000000000000000000000000000000', - 'nano_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou', - '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D', + NANO_TEST_VECTORS.RECEIVE_BLOCK.account, + NANO_TEST_VECTORS.RECEIVE_BLOCK.balance, + NANO_TEST_VECTORS.RECEIVE_BLOCK.link, + '0', + NANO_TEST_VECTORS.RECEIVE_BLOCK.representative, + NANO_TEST_VECTORS.RECEIVE_BLOCK.previous ) - await block.sign('781186FB9EF17DB6E3D1056550D9FAE5D5BBADA6A6BC370E4CBB938B1DC71DA3') - assert.equal(block.signature, 'F25D751AD0379A5718E08F3773DA6061A9E18842EF5615163C7F207B804CC2C5DD2720CFCE5FE6A78E4CC108DD9CAB65051526403FA2C24A1ED943BB4EA7880B') + await block.sign(NANO_TEST_VECTORS.RECEIVE_BLOCK.key) + assert.equal(block.signature, NANO_TEST_VECTORS.RECEIVE_BLOCK.signature) assert.equal(block.work, '') }) it('should create a valid signature for a send block', async () => { - const work = 'fbffed7c73b61367' const block = new SendBlock( - 'nano_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx', - '5618869000000000000000000000000', - 'nano_1q3hqecaw15cjt7thbtxu3pbzr1eihtzzpzxguoc37bj1wc5ffoh7w74gi6p', - '2000000000000000000000000000000', - 'nano_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou', - '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D', - work, + NANO_TEST_VECTORS.SEND_BLOCK.account, + NANO_TEST_VECTORS.SEND_BLOCK.balance, + NANO_TEST_VECTORS.SEND_BLOCK.link, + '0', + NANO_TEST_VECTORS.SEND_BLOCK.representative, + NANO_TEST_VECTORS.SEND_BLOCK.previous, + NANO_TEST_VECTORS.SEND_BLOCK.work ) - await block.sign('781186FB9EF17DB6E3D1056550D9FAE5D5BBADA6A6BC370E4CBB938B1DC71DA3') - assert.equal(block.signature.toUpperCase(), '79240D56231EF1885F354473733AF158DC6DA50E53836179565A20C0BE89D473ED3FF8CD11545FF0ED162A0B2C4626FD6BF84518568F8BB965A4884C7C32C205') - assert.equal(block.work, work) + await block.sign(NANO_TEST_VECTORS.SEND_BLOCK.key) + assert.equal(block.signature, NANO_TEST_VECTORS.SEND_BLOCK.signature) }) it('should create a valid signature for a send block without work', async () => { const block = new SendBlock( - 'nano_1e5aqegc1jb7qe964u4adzmcezyo6o146zb8hm6dft8tkp79za3sxwjym5rx', - '5618869000000000000000000000000', - 'nano_1q3hqecaw15cjt7thbtxu3pbzr1eihtzzpzxguoc37bj1wc5ffoh7w74gi6p', - '2000000000000000000000000000000', - 'nano_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou', - '92BA74A7D6DC7557F3EDA95ADC6341D51AC777A0A6FF0688A5C492AB2B2CB40D', + NANO_TEST_VECTORS.SEND_BLOCK.account, + NANO_TEST_VECTORS.SEND_BLOCK.balance, + NANO_TEST_VECTORS.SEND_BLOCK.link, + '0', + NANO_TEST_VECTORS.SEND_BLOCK.representative, + NANO_TEST_VECTORS.SEND_BLOCK.previous ) - await block.sign('781186FB9EF17DB6E3D1056550D9FAE5D5BBADA6A6BC370E4CBB938B1DC71DA3') - assert.equal(block.signature.toUpperCase(), '79240D56231EF1885F354473733AF158DC6DA50E53836179565A20C0BE89D473ED3FF8CD11545FF0ED162A0B2C4626FD6BF84518568F8BB965A4884C7C32C205') + await block.sign(NANO_TEST_VECTORS.SEND_BLOCK.key) + assert.equal(block.signature, NANO_TEST_VECTORS.SEND_BLOCK.signature) assert.equal(block.work, '') })