From 0afbd1f240a6a755658a9baf6a9bb2528187e5e4 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Tue, 25 Jan 2022 14:57:29 -0700 Subject: [PATCH] Correct the types of variable-length fields for ZIP 244 test vectors. Signed-off-by: Daira Hopwood --- test-vectors/rust/zip_0244.rs | 44 +++++++++++++++++----------------- zcash_test_vectors/output.py | 3 ++- zcash_test_vectors/zip_0244.py | 4 ++-- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/test-vectors/rust/zip_0244.rs b/test-vectors/rust/zip_0244.rs index 5d9fefd..0225db5 100644 --- a/test-vectors/rust/zip_0244.rs +++ b/test-vectors/rust/zip_0244.rs @@ -2,8 +2,8 @@ tx: Vec, txid: [u8; 32], auth_digest: [u8; 32], - amounts: [i64; 2], - script_pubkeys: [Vec; 2], + amounts: Vec, + script_pubkeys: Vec>, transparent_input: Option, sighash_shielded: [u8; 32], sighash_all: Option<[u8; 32]>, @@ -26,10 +26,10 @@ auth_digest: [ 0x1b, 0x60, 0x46, 0xb6, 0x82, 0xf6, 0x9d, 0xb1, 0x66, 0x65, 0x63, 0x2d, 0x21, 0xdc, 0x7f, 0x83, 0x46, 0xb2, 0x82, 0xec, 0x04, 0xb8, 0x40, 0xf2, 0x45, 0x1d, 0x09, 0xc0, 0x86, 0x3c, 0xda, 0x6b ], - amounts: [ + amounts: vec![ 1800841178198868, ], - script_pubkeys: [ + script_pubkeys: vec![ vec![ 0x65, 0x00, 0x51 ], @@ -63,9 +63,9 @@ auth_digest: [ 0x36, 0x4e, 0xa0, 0xbf, 0x6b, 0xd4, 0xb4, 0xa6, 0x26, 0xdc, 0xcf, 0x0f, 0x96, 0xca, 0x1b, 0x0c, 0x3b, 0x4c, 0x46, 0x81, 0x60, 0x24, 0x7b, 0xce, 0x13, 0xf4, 0x68, 0x98, 0x84, 0x10, 0x4e, 0xb1 ], - amounts: [ + amounts: vec![ ], - script_pubkeys: [ + script_pubkeys: vec![ ], transparent_input: None, sighash_shielded: [ @@ -88,9 +88,9 @@ auth_digest: [ 0xd4, 0xfb, 0x0a, 0x17, 0xd1, 0x4a, 0xee, 0x9b, 0x7f, 0x67, 0x05, 0xff, 0x78, 0xa1, 0x43, 0xba, 0x07, 0xae, 0x4c, 0x59, 0xb2, 0x3c, 0x84, 0x77, 0xd0, 0xfd, 0x72, 0xf5, 0x70, 0x97, 0xb7, 0x38 ], - amounts: [ + amounts: vec![ ], - script_pubkeys: [ + script_pubkeys: vec![ ], transparent_input: None, sighash_shielded: [ @@ -113,9 +113,9 @@ auth_digest: [ 0xd4, 0xfb, 0x0a, 0x17, 0xd1, 0x4a, 0xee, 0x9b, 0x7f, 0x67, 0x05, 0xff, 0x78, 0xa1, 0x43, 0xba, 0x07, 0xae, 0x4c, 0x59, 0xb2, 0x3c, 0x84, 0x77, 0xd0, 0xfd, 0x72, 0xf5, 0x70, 0x97, 0xb7, 0x38 ], - amounts: [ + amounts: vec![ ], - script_pubkeys: [ + script_pubkeys: vec![ ], transparent_input: None, sighash_shielded: [ @@ -138,12 +138,12 @@ auth_digest: [ 0x4b, 0x58, 0x88, 0x55, 0x8d, 0x0e, 0xa2, 0x9a, 0x24, 0x27, 0x28, 0x16, 0xb4, 0x14, 0x2b, 0x9d, 0xc6, 0x82, 0x56, 0x81, 0xc0, 0xd6, 0xed, 0x99, 0x09, 0x76, 0x35, 0x55, 0x40, 0xed, 0x45, 0xf7 ], - amounts: [ + amounts: vec![ 1848924248978091, 447389782351145, 620151782842275, ], - script_pubkeys: [ + script_pubkeys: vec![ vec![ 0xac, 0x00, 0x00 ], @@ -187,11 +187,11 @@ auth_digest: [ 0xd9, 0xb3, 0xc9, 0x6f, 0xb0, 0xdd, 0xe3, 0xc7, 0x9d, 0xeb, 0x95, 0x59, 0x29, 0x8f, 0x74, 0x89, 0x29, 0x71, 0x12, 0x7e, 0xae, 0x2f, 0x4b, 0x02, 0x83, 0x91, 0x95, 0xb0, 0xe4, 0x05, 0x3b, 0x4b ], - amounts: [ + amounts: vec![ 1561051182746413, 1535468271734483, ], - script_pubkeys: [ + script_pubkeys: vec![ vec![ 0x65, 0x6a, 0x51, 0x6a, 0xac, 0x51, 0x6a, 0x65, 0x52 ], @@ -232,9 +232,9 @@ auth_digest: [ 0xb7, 0xac, 0x05, 0x72, 0x8f, 0x3c, 0xbb, 0xf8, 0xf8, 0xa6, 0x03, 0xcc, 0xaf, 0xe4, 0x84, 0x5f, 0x4a, 0x45, 0x75, 0x73, 0xf9, 0x72, 0xcc, 0xdf, 0x4b, 0x62, 0xa6, 0xbf, 0x82, 0x20, 0xe0, 0x23 ], - amounts: [ + amounts: vec![ ], - script_pubkeys: [ + script_pubkeys: vec![ ], transparent_input: None, sighash_shielded: [ @@ -257,12 +257,12 @@ auth_digest: [ 0xd0, 0x4b, 0x70, 0xd2, 0xc7, 0x5c, 0x3b, 0x46, 0x1f, 0xbc, 0x57, 0xc3, 0x20, 0xe4, 0x4a, 0xb8, 0x6c, 0x40, 0x94, 0x27, 0xfb, 0x74, 0x21, 0x84, 0x38, 0x9c, 0xff, 0xdd, 0x3d, 0x5f, 0x3d, 0x91 ], - amounts: [ + amounts: vec![ 787459282010655, 1685382316228727, 1715663111103469, ], - script_pubkeys: [ + script_pubkeys: vec![ vec![ 0x65, 0x6a ], @@ -302,12 +302,12 @@ auth_digest: [ 0x2d, 0x10, 0xd0, 0x39, 0x98, 0x21, 0x71, 0xf9, 0xd2, 0xa7, 0x63, 0xe6, 0x5d, 0xf1, 0x29, 0x91, 0xae, 0xd0, 0x55, 0x6c, 0x00, 0x35, 0x1d, 0xc4, 0x03, 0xb7, 0xcc, 0x8b, 0x4c, 0x91, 0xe2, 0x78 ], - amounts: [ + amounts: vec![ 1076763594431866, 316847576141144, 1780844721475339, ], - script_pubkeys: [ + script_pubkeys: vec![ vec![ 0x00, 0x65, 0x51, 0xac, 0x65, 0x63, 0x00, 0x53 ], @@ -347,11 +347,11 @@ auth_digest: [ 0xe9, 0x69, 0x9a, 0xbf, 0xb3, 0x96, 0x41, 0xc4, 0xc0, 0x4b, 0x49, 0xd7, 0x02, 0xfc, 0x35, 0xa0, 0xe9, 0x1c, 0xe8, 0xb6, 0x53, 0xf5, 0xbf, 0xb4, 0x91, 0x14, 0xab, 0xec, 0xc1, 0x64, 0x19, 0x5c ], - amounts: [ + amounts: vec![ 1399781968202734, 1999413718097392, ], - script_pubkeys: [ + script_pubkeys: vec![ vec![ 0x00, 0x53, 0x00 ], diff --git a/zcash_test_vectors/output.py b/zcash_test_vectors/output.py index 552fccd..83ef4f3 100644 --- a/zcash_test_vectors/output.py +++ b/zcash_test_vectors/output.py @@ -149,9 +149,10 @@ def tv_part_rust(name, value, config, indent=3): elif type(value) == int: tv_int_rust(name, value, pad) elif type(value) == list: - print('''%s%s: [''' % ( + print('''%s%s: %s[''' % ( pad, name, + 'vec!' if config['rust_type'].startswith('Vec<') else '', )) for item in value: if 'Vec' in config['rust_type']: diff --git a/zcash_test_vectors/zip_0244.py b/zcash_test_vectors/zip_0244.py index 7d53e4f..d89740a 100755 --- a/zcash_test_vectors/zip_0244.py +++ b/zcash_test_vectors/zip_0244.py @@ -400,9 +400,9 @@ def main(): ('tx', {'rust_type': 'Vec', 'bitcoin_flavoured': False}), ('txid', '[u8; 32]'), ('auth_digest', '[u8; 32]'), - ('amounts', '[i64; %d]' % len(t_inputs)), + ('amounts', {'rust_type': 'Vec'}), ('script_pubkeys', { - 'rust_type': '[Vec; %d]' % len(t_inputs), + 'rust_type': 'Vec>', 'bitcoin_flavoured': False, }), ('transparent_input', {