From 9ef3e8c68a0028f191a588ad736071175234e1c1 Mon Sep 17 00:00:00 2001 From: Michael Zaikin Date: Fri, 18 Oct 2024 15:59:19 +0100 Subject: [PATCH 1/3] Utreexo integration tests --- packages/client/tests/data/ignore | 0 packages/utreexo/Scarb.toml | 1 + packages/utreexo/src/lib.cairo | 1 + packages/utreexo/src/stump/proof.cairo | 2 +- packages/utreexo/src/test.cairo | 43 ++++++++++++ .../tests/data/deletion_test_case_0.json | 37 +++++++++++ .../tests/data/deletion_test_case_1.json | 39 +++++++++++ .../tests/data/deletion_test_case_10.json | 53 +++++++++++++++ .../tests/data/deletion_test_case_11.json | 43 ++++++++++++ .../tests/data/deletion_test_case_12.json | 38 +++++++++++ .../tests/data/deletion_test_case_13.json | 41 ++++++++++++ .../tests/data/deletion_test_case_2.json | 47 +++++++++++++ .../tests/data/deletion_test_case_3.json | 51 ++++++++++++++ .../tests/data/deletion_test_case_4.json | 65 ++++++++++++++++++ .../tests/data/deletion_test_case_5.json | 66 +++++++++++++++++++ .../tests/data/deletion_test_case_6.json | 63 ++++++++++++++++++ .../tests/data/deletion_test_case_7.json | 65 ++++++++++++++++++ .../tests/data/deletion_test_case_8.json | 64 ++++++++++++++++++ .../tests/data/deletion_test_case_9.json | 53 +++++++++++++++ packages/utreexo/tests/data/ignore | 5 ++ scripts/data/integration_tests.sh | 12 +++- 21 files changed, 786 insertions(+), 3 deletions(-) create mode 100644 packages/client/tests/data/ignore create mode 100644 packages/utreexo/src/test.cairo create mode 100644 packages/utreexo/tests/data/deletion_test_case_0.json create mode 100644 packages/utreexo/tests/data/deletion_test_case_1.json create mode 100644 packages/utreexo/tests/data/deletion_test_case_10.json create mode 100644 packages/utreexo/tests/data/deletion_test_case_11.json create mode 100644 packages/utreexo/tests/data/deletion_test_case_12.json create mode 100644 packages/utreexo/tests/data/deletion_test_case_13.json create mode 100644 packages/utreexo/tests/data/deletion_test_case_2.json create mode 100644 packages/utreexo/tests/data/deletion_test_case_3.json create mode 100644 packages/utreexo/tests/data/deletion_test_case_4.json create mode 100644 packages/utreexo/tests/data/deletion_test_case_5.json create mode 100644 packages/utreexo/tests/data/deletion_test_case_6.json create mode 100644 packages/utreexo/tests/data/deletion_test_case_7.json create mode 100644 packages/utreexo/tests/data/deletion_test_case_8.json create mode 100644 packages/utreexo/tests/data/deletion_test_case_9.json create mode 100644 packages/utreexo/tests/data/ignore diff --git a/packages/client/tests/data/ignore b/packages/client/tests/data/ignore new file mode 100644 index 00000000..e69de29b diff --git a/packages/utreexo/Scarb.toml b/packages/utreexo/Scarb.toml index e823b1f8..31b1bf00 100644 --- a/packages/utreexo/Scarb.toml +++ b/packages/utreexo/Scarb.toml @@ -12,3 +12,4 @@ cairo_test.workspace = true [scripts] # TODO: cairo lint lint = "scarb fmt" +test = "scarb build && ../../scripts/data/integration_tests.sh" \ No newline at end of file diff --git a/packages/utreexo/src/lib.cairo b/packages/utreexo/src/lib.cairo index dd1760e4..1b1b80ca 100644 --- a/packages/utreexo/src/lib.cairo +++ b/packages/utreexo/src/lib.cairo @@ -8,6 +8,7 @@ pub mod stump { pub mod proof; pub mod accumulator; } +pub mod test; use core::poseidon::PoseidonTrait; use core::hash::{HashStateTrait, HashStateExTrait}; diff --git a/packages/utreexo/src/stump/proof.cairo b/packages/utreexo/src/stump/proof.cairo index 3e46b4ac..832ceecc 100644 --- a/packages/utreexo/src/stump/proof.cairo +++ b/packages/utreexo/src/stump/proof.cairo @@ -5,7 +5,7 @@ use utils::{numeric::u64_next_power_of_two, sort::bubble_sort}; /// Utreexo inclusion proof for multiple outputs. /// Compatible with https://github.com/utreexo/utreexo -#[derive(Drop, Copy)] +#[derive(Drop, Copy, Serde, Debug)] pub struct UtreexoBatchProof { /// List of sibling nodes required to calculate the roots. pub proof: Span, diff --git a/packages/utreexo/src/test.cairo b/packages/utreexo/src/test.cairo new file mode 100644 index 00000000..daf97b6c --- /dev/null +++ b/packages/utreexo/src/test.cairo @@ -0,0 +1,43 @@ +use crate::stump::state::UtreexoStumpState; +use crate::stump::proof::UtreexoBatchProof; +use crate::stump::accumulator::StumpUtreexoAccumulator; +use core::testing::get_available_gas; + +#[derive(Drop, Serde, Debug)] +struct Args { + state: UtreexoStumpState, + proof: UtreexoBatchProof, + leaves_to_del: Array, + leaves_to_add: Array, + expected_state: UtreexoStumpState, +} + +fn main(mut arguments: Span, _flags: felt252) { + let mut gas_before = get_available_gas(); + + let Args { mut state, proof, leaves_to_del, leaves_to_add: _, expected_state } = + Serde::deserialize( + ref arguments + ) + .expect('Failed to deserialize'); + + match state.verify_and_delete(@proof, leaves_to_del.span()) { + Result::Ok(new_state) => { state = new_state; }, + Result::Err(err) => { + println!("FAIL: gas_spent={} error='{:?}'", gas_before - get_available_gas(), err); + panic!(); + } + } + + if state != expected_state { + println!( + "FAIL: gas_spent={} error='expected state {:?}, actual {:?}'", + gas_before - get_available_gas(), + expected_state, + state + ); + panic!(); + } + + println!("OK: gas_spent={}", gas_before - get_available_gas()); +} diff --git a/packages/utreexo/tests/data/deletion_test_case_0.json b/packages/utreexo/tests/data/deletion_test_case_0.json new file mode 100644 index 00000000..9868fdb5 --- /dev/null +++ b/packages/utreexo/tests/data/deletion_test_case_0.json @@ -0,0 +1,37 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1010147253610699894986241683624609428739638206544914327400350896031110287324 + } + ], + "leaves": 8 + }, + "proof": { + "nodes": [ + 0, + 6, + 359114454570462701179676018441683730149326686283278794303413350979946254235, + 3613143053999770272842665473502706307602279676970981102529837756866990003067 + ], + "targets": [ + 1, + 7 + ] + }, + "leaves_to_del": [ + 1, + 7 + ], + "leaves_to_add": [], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 2623024148755398637531760140996385406771006182960749518965731515106835184482 + } + ], + "leaves": 8 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/deletion_test_case_1.json b/packages/utreexo/tests/data/deletion_test_case_1.json new file mode 100644 index 00000000..4412a11c --- /dev/null +++ b/packages/utreexo/tests/data/deletion_test_case_1.json @@ -0,0 +1,39 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1010147253610699894986241683624609428739638206544914327400350896031110287324 + } + ], + "leaves": 8 + }, + "proof": { + "nodes": [ + 0, + 4, + 6, + 359114454570462701179676018441683730149326686283278794303413350979946254235 + ], + "targets": [ + 1, + 5, + 7 + ] + }, + "leaves_to_del": [ + 1, + 5, + 7 + ], + "leaves_to_add": [], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 551674533840830050473419886120072409925785030121488629468288542069393223983 + } + ], + "leaves": 8 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/deletion_test_case_10.json b/packages/utreexo/tests/data/deletion_test_case_10.json new file mode 100644 index 00000000..a1330e5d --- /dev/null +++ b/packages/utreexo/tests/data/deletion_test_case_10.json @@ -0,0 +1,53 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1010147253610699894986241683624609428739638206544914327400350896031110287324 + }, + { + "variant_id": 0, + "value": 2224391216833402212724735773212940252356536072547264452695587483243907176367 + } + ], + "leaves": 12 + }, + "proof": { + "nodes": [ + 1, + 9, + 359114454570462701179676018441683730149326686283278794303413350979946254235, + 3567352371131958462633700980001500490451506860561008566474965365048073632618 + ], + "targets": [ + 0, + 4, + 5, + 6, + 7, + 8 + ] + }, + "leaves_to_del": [ + 0, + 4, + 5, + 6, + 7, + 8 + ], + "leaves_to_add": [], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 841749818242255598355457760484755763160419106386224879307430326240151869062 + }, + { + "variant_id": 0, + "value": 1551534320701356863254738291358041183709275983112386770096580481322892724373 + } + ], + "leaves": 12 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/deletion_test_case_11.json b/packages/utreexo/tests/data/deletion_test_case_11.json new file mode 100644 index 00000000..7ff8eaf8 --- /dev/null +++ b/packages/utreexo/tests/data/deletion_test_case_11.json @@ -0,0 +1,43 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1010147253610699894986241683624609428739638206544914327400350896031110287324 + } + ], + "leaves": 8 + }, + "proof": { + "nodes": [], + "targets": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7 + ] + }, + "leaves_to_del": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7 + ], + "leaves_to_add": [], + "expected_state": { + "roots": [ + { + "variant_id": 1 + } + ], + "leaves": 8 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/deletion_test_case_12.json b/packages/utreexo/tests/data/deletion_test_case_12.json new file mode 100644 index 00000000..921c8eb6 --- /dev/null +++ b/packages/utreexo/tests/data/deletion_test_case_12.json @@ -0,0 +1,38 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1010147253610699894986241683624609428739638206544914327400350896031110287324 + } + ], + "leaves": 8 + }, + "proof": { + "nodes": [ + 2920447154653459698578961030005574439730780339384884329678783637696763668074 + ], + "targets": [ + 0, + 1, + 2, + 3 + ] + }, + "leaves_to_del": [ + 0, + 1, + 2, + 3 + ], + "leaves_to_add": [], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 2920447154653459698578961030005574439730780339384884329678783637696763668074 + } + ], + "leaves": 8 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/deletion_test_case_13.json b/packages/utreexo/tests/data/deletion_test_case_13.json new file mode 100644 index 00000000..938ecba7 --- /dev/null +++ b/packages/utreexo/tests/data/deletion_test_case_13.json @@ -0,0 +1,41 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1010147253610699894986241683624609428739638206544914327400350896031110287324 + } + ], + "leaves": 8 + }, + "proof": { + "nodes": [ + 1, + 3, + 5, + 7 + ], + "targets": [ + 0, + 2, + 4, + 6 + ] + }, + "leaves_to_del": [ + 0, + 2, + 4, + 6 + ], + "leaves_to_add": [], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 2007301334687130043979282869173510263602829546765086564193349908634632922671 + } + ], + "leaves": 8 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/deletion_test_case_2.json b/packages/utreexo/tests/data/deletion_test_case_2.json new file mode 100644 index 00000000..607319ae --- /dev/null +++ b/packages/utreexo/tests/data/deletion_test_case_2.json @@ -0,0 +1,47 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 2778277074578782368986165095004756321440748237082580104984033528445453379385 + }, + { + "variant_id": 0, + "value": 1187458855538029538020919690451164587984966864934526448127883456389212101807 + } + ], + "leaves": 20 + }, + "proof": { + "nodes": [ + 0, + 11, + 359114454570462701179676018441683730149326686283278794303413350979946254235, + 3115762988631556491925147498418117978906005591291390166955707455104569660364, + 2920447154653459698578961030005574439730780339384884329678783637696763668074, + 1813826121834271504980511192245059557593697196840757755209576674667633130596 + ], + "targets": [ + 1, + 10 + ] + }, + "leaves_to_del": [ + 1, + 10 + ], + "leaves_to_add": [], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 2830407139356916834023424457422660277807343551646444886940602849914950685391 + }, + { + "variant_id": 0, + "value": 1187458855538029538020919690451164587984966864934526448127883456389212101807 + } + ], + "leaves": 20 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/deletion_test_case_3.json b/packages/utreexo/tests/data/deletion_test_case_3.json new file mode 100644 index 00000000..30003925 --- /dev/null +++ b/packages/utreexo/tests/data/deletion_test_case_3.json @@ -0,0 +1,51 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 2778277074578782368986165095004756321440748237082580104984033528445453379385 + }, + { + "variant_id": 0, + "value": 1187458855538029538020919690451164587984966864934526448127883456389212101807 + } + ], + "leaves": 20 + }, + "proof": { + "nodes": [ + 0, + 11, + 17, + 359114454570462701179676018441683730149326686283278794303413350979946254235, + 3115762988631556491925147498418117978906005591291390166955707455104569660364, + 3325741655535215356957865124770093176746675852005881929681191209366655117343, + 2920447154653459698578961030005574439730780339384884329678783637696763668074, + 1813826121834271504980511192245059557593697196840757755209576674667633130596 + ], + "targets": [ + 1, + 10, + 16 + ] + }, + "leaves_to_del": [ + 1, + 10, + 16 + ], + "leaves_to_add": [], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 2830407139356916834023424457422660277807343551646444886940602849914950685391 + }, + { + "variant_id": 0, + "value": 3518456284848065536877573702921456496163509108617676224404664807737058463259 + } + ], + "leaves": 20 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/deletion_test_case_4.json b/packages/utreexo/tests/data/deletion_test_case_4.json new file mode 100644 index 00000000..6d01e617 --- /dev/null +++ b/packages/utreexo/tests/data/deletion_test_case_4.json @@ -0,0 +1,65 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1010147253610699894986241683624609428739638206544914327400350896031110287324 + }, + { + "variant_id": 0, + "value": 2224391216833402212724735773212940252356536072547264452695587483243907176367 + }, + { + "variant_id": 0, + "value": 3009277733733429566191908933097273596911357184294896938062356457901603258437 + }, + { + "variant_id": 0, + "value": 14 + } + ], + "leaves": 15 + }, + "proof": { + "nodes": [ + 0, + 4, + 11, + 359114454570462701179676018441683730149326686283278794303413350979946254235, + 2476911194812244264213538976037850550079366744233323933541290896048104351430, + 3115762988631556491925147498418117978906005591291390166955707455104569660364 + ], + "targets": [ + 1, + 10, + 5 + ] + }, + "leaves_to_del": [ + 1, + 10, + 5 + ], + "leaves_to_add": [], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 2774269110009363850047571152130147152783590739705553396730017152246271218557 + }, + { + "variant_id": 0, + "value": 2434209091672931462468799562562031916768655108202953779055187960434828922032 + }, + { + "variant_id": 0, + "value": 3009277733733429566191908933097273596911357184294896938062356457901603258437 + }, + { + "variant_id": 0, + "value": 14 + } + ], + "leaves": 15 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/deletion_test_case_5.json b/packages/utreexo/tests/data/deletion_test_case_5.json new file mode 100644 index 00000000..a96f7620 --- /dev/null +++ b/packages/utreexo/tests/data/deletion_test_case_5.json @@ -0,0 +1,66 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1010147253610699894986241683624609428739638206544914327400350896031110287324 + }, + { + "variant_id": 0, + "value": 2224391216833402212724735773212940252356536072547264452695587483243907176367 + }, + { + "variant_id": 0, + "value": 3009277733733429566191908933097273596911357184294896938062356457901603258437 + }, + { + "variant_id": 0, + "value": 14 + } + ], + "leaves": 15 + }, + "proof": { + "nodes": [ + 4, + 11, + 359114454570462701179676018441683730149326686283278794303413350979946254235, + 2476911194812244264213538976037850550079366744233323933541290896048104351430, + 3115762988631556491925147498418117978906005591291390166955707455104569660364 + ], + "targets": [ + 0, + 1, + 10, + 5 + ] + }, + "leaves_to_del": [ + 0, + 1, + 10, + 5 + ], + "leaves_to_add": [], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 497732802815518640976532643405733396450470267615991171885882933583320966954 + }, + { + "variant_id": 0, + "value": 2434209091672931462468799562562031916768655108202953779055187960434828922032 + }, + { + "variant_id": 0, + "value": 3009277733733429566191908933097273596911357184294896938062356457901603258437 + }, + { + "variant_id": 0, + "value": 14 + } + ], + "leaves": 15 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/deletion_test_case_6.json b/packages/utreexo/tests/data/deletion_test_case_6.json new file mode 100644 index 00000000..47409461 --- /dev/null +++ b/packages/utreexo/tests/data/deletion_test_case_6.json @@ -0,0 +1,63 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1010147253610699894986241683624609428739638206544914327400350896031110287324 + }, + { + "variant_id": 0, + "value": 2224391216833402212724735773212940252356536072547264452695587483243907176367 + }, + { + "variant_id": 0, + "value": 3009277733733429566191908933097273596911357184294896938062356457901603258437 + }, + { + "variant_id": 0, + "value": 14 + } + ], + "leaves": 15 + }, + "proof": { + "nodes": [ + 4, + 359114454570462701179676018441683730149326686283278794303413350979946254235, + 2476911194812244264213538976037850550079366744233323933541290896048104351430 + ], + "targets": [ + 0, + 1, + 5, + 14 + ] + }, + "leaves_to_del": [ + 0, + 1, + 5, + 14 + ], + "leaves_to_add": [], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 497732802815518640976532643405733396450470267615991171885882933583320966954 + }, + { + "variant_id": 0, + "value": 2224391216833402212724735773212940252356536072547264452695587483243907176367 + }, + { + "variant_id": 0, + "value": 3009277733733429566191908933097273596911357184294896938062356457901603258437 + }, + { + "variant_id": 1 + } + ], + "leaves": 15 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/deletion_test_case_7.json b/packages/utreexo/tests/data/deletion_test_case_7.json new file mode 100644 index 00000000..235f2d88 --- /dev/null +++ b/packages/utreexo/tests/data/deletion_test_case_7.json @@ -0,0 +1,65 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1010147253610699894986241683624609428739638206544914327400350896031110287324 + }, + { + "variant_id": 0, + "value": 2224391216833402212724735773212940252356536072547264452695587483243907176367 + }, + { + "variant_id": 0, + "value": 3009277733733429566191908933097273596911357184294896938062356457901603258437 + }, + { + "variant_id": 0, + "value": 14 + } + ], + "leaves": 15 + }, + "proof": { + "nodes": [ + 0, + 2, + 4, + 7 + ], + "targets": [ + 1, + 6, + 5, + 3 + ] + }, + "leaves_to_del": [ + 1, + 6, + 5, + 3 + ], + "leaves_to_add": [], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 2542834485472201375063952267657234229360599181580459538243740237309237489997 + }, + { + "variant_id": 0, + "value": 2224391216833402212724735773212940252356536072547264452695587483243907176367 + }, + { + "variant_id": 0, + "value": 3009277733733429566191908933097273596911357184294896938062356457901603258437 + }, + { + "variant_id": 0, + "value": 14 + } + ], + "leaves": 15 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/deletion_test_case_8.json b/packages/utreexo/tests/data/deletion_test_case_8.json new file mode 100644 index 00000000..d2952f7e --- /dev/null +++ b/packages/utreexo/tests/data/deletion_test_case_8.json @@ -0,0 +1,64 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 2165915913108448461952915035199992115188274826980627306957797425653511112322 + }, + { + "variant_id": 0, + "value": 2233258972414885866189363096992191546710327778084747172639566606002708566944 + }, + { + "variant_id": 0, + "value": 642347556491670165283398532129323576556514980317062989585571746245257915465 + } + ], + "leaves": 100 + }, + "proof": { + "nodes": [ + 3, + 8, + 2476911194812244264213538976037850550079366744233323933541290896048104351430, + 3567352371131958462633700980001500490451506860561008566474965365048073632618, + 1813826121834271504980511192245059557593697196840757755209576674667633130596, + 1858980809370786577311980994727901038167608739072537272840848798584819431473, + 1024769225221052025281254286802090898314321261159479176848884875817503580840 + ], + "targets": [ + 0, + 1, + 2, + 4, + 5, + 9 + ] + }, + "leaves_to_del": [ + 0, + 1, + 2, + 4, + 5, + 9 + ], + "leaves_to_add": [], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 394259646554252767984184254989108416967864354151675101674138588881099113659 + }, + { + "variant_id": 0, + "value": 2233258972414885866189363096992191546710327778084747172639566606002708566944 + }, + { + "variant_id": 0, + "value": 642347556491670165283398532129323576556514980317062989585571746245257915465 + } + ], + "leaves": 100 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/deletion_test_case_9.json b/packages/utreexo/tests/data/deletion_test_case_9.json new file mode 100644 index 00000000..2afe53a1 --- /dev/null +++ b/packages/utreexo/tests/data/deletion_test_case_9.json @@ -0,0 +1,53 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 2165915913108448461952915035199992115188274826980627306957797425653511112322 + }, + { + "variant_id": 0, + "value": 2233258972414885866189363096992191546710327778084747172639566606002708566944 + }, + { + "variant_id": 0, + "value": 642347556491670165283398532129323576556514980317062989585571746245257915465 + } + ], + "leaves": 100 + }, + "proof": { + "nodes": [ + 39, + 3445535368271015044293121856705513217511168631048114526337134830187316161922, + 1591239225204504744081254413392096259071062676306271598794215164553405364886, + 1547130669050410027801432723566156116714889887376207199769468845503460861186, + 2258044221655052220972134952667238440136729258761489832316394515872580012696, + 1164355837085349317552079963264680967657912756202432097157524592786311377117 + ], + "targets": [ + 38 + ] + }, + "leaves_to_del": [ + 38 + ], + "leaves_to_add": [], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 929158566745605449453211918707771431050728700323714963056620405087827552396 + }, + { + "variant_id": 0, + "value": 2233258972414885866189363096992191546710327778084747172639566606002708566944 + }, + { + "variant_id": 0, + "value": 642347556491670165283398532129323576556514980317062989585571746245257915465 + } + ], + "leaves": 100 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/ignore b/packages/utreexo/tests/data/ignore new file mode 100644 index 00000000..f0909d68 --- /dev/null +++ b/packages/utreexo/tests/data/ignore @@ -0,0 +1,5 @@ +deletion_test_case_3.json +deletion_test_case_4.json +deletion_test_case_5.json +deletion_test_case_6.json +deletion_test_case_10.json diff --git a/scripts/data/integration_tests.sh b/scripts/data/integration_tests.sh index cf32e288..edc0c2ec 100755 --- a/scripts/data/integration_tests.sh +++ b/scripts/data/integration_tests.sh @@ -51,13 +51,21 @@ ignored_files=( "tests/data/utreexo_169.json", # Unexpected root (TODO: create issue) # "tests/data/full_478557.json", #runs on server ) + +ignore_file="tests/data/ignore" +if [[ -f "$ignore_file" ]]; then + while IFS= read -r line; do + ignored_files+="tests/data/$line" + done < "$ignore_file" +fi + ignored="${ignored_files[@]}" # If no test files are explicitly specified, default to tests/data/* if [[ $fullonly -eq 1 && ${#test_files[@]} -eq 0 ]]; then - test_files=("tests/data"/full*) + test_files=("tests/data"/full*.json) elif [[ ${#test_files[@]} -eq 0 ]]; then - test_files=("tests/data"/*) + test_files=("tests/data"/*.json) fi if [[ $execute_scripts -eq 1 ]]; then From 845a7a4a9bcc575f4bdd46e36c1c83d8df75656b Mon Sep 17 00:00:00 2001 From: Michael Zaikin Date: Fri, 18 Oct 2024 16:23:38 +0100 Subject: [PATCH 2/3] Insertion tests (ignored) --- packages/utreexo/Scarb.toml | 2 +- packages/utreexo/tests/data/ignore | 4 + .../tests/data/insertion_test_case_0.json | 30 +++ .../tests/data/insertion_test_case_1.json | 37 +++ .../tests/data/insertion_test_case_2.json | 49 ++++ .../tests/data/insertion_test_case_3.json | 237 ++++++++++++++++++ 6 files changed, 358 insertions(+), 1 deletion(-) create mode 100644 packages/utreexo/tests/data/insertion_test_case_0.json create mode 100644 packages/utreexo/tests/data/insertion_test_case_1.json create mode 100644 packages/utreexo/tests/data/insertion_test_case_2.json create mode 100644 packages/utreexo/tests/data/insertion_test_case_3.json diff --git a/packages/utreexo/Scarb.toml b/packages/utreexo/Scarb.toml index 31b1bf00..b6836d01 100644 --- a/packages/utreexo/Scarb.toml +++ b/packages/utreexo/Scarb.toml @@ -12,4 +12,4 @@ cairo_test.workspace = true [scripts] # TODO: cairo lint lint = "scarb fmt" -test = "scarb build && ../../scripts/data/integration_tests.sh" \ No newline at end of file +test = "scarb cairo-test && ../../scripts/data/integration_tests.sh" \ No newline at end of file diff --git a/packages/utreexo/tests/data/ignore b/packages/utreexo/tests/data/ignore index f0909d68..009ac891 100644 --- a/packages/utreexo/tests/data/ignore +++ b/packages/utreexo/tests/data/ignore @@ -3,3 +3,7 @@ deletion_test_case_4.json deletion_test_case_5.json deletion_test_case_6.json deletion_test_case_10.json +insertion_test_case_0.json +insertion_test_case_1.json +insertion_test_case_2.json +insertion_test_case_3.json diff --git a/packages/utreexo/tests/data/insertion_test_case_0.json b/packages/utreexo/tests/data/insertion_test_case_0.json new file mode 100644 index 00000000..8b269ec4 --- /dev/null +++ b/packages/utreexo/tests/data/insertion_test_case_0.json @@ -0,0 +1,30 @@ +{ + "state": { + "roots": [], + "leaves": 0 + }, + "proof": { + "nodes": [], + "targets": [] + }, + "leaves_to_del": [], + "leaves_to_add": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7 + ], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 1010147253610699894986241683624609428739638206544914327400350896031110287324 + } + ], + "leaves": 8 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/insertion_test_case_1.json b/packages/utreexo/tests/data/insertion_test_case_1.json new file mode 100644 index 00000000..c0c251af --- /dev/null +++ b/packages/utreexo/tests/data/insertion_test_case_1.json @@ -0,0 +1,37 @@ +{ + "state": { + "roots": [], + "leaves": 0 + }, + "proof": { + "nodes": [], + "targets": [] + }, + "leaves_to_del": [], + "leaves_to_add": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6 + ], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 1229371501456391789924831928153470943555736434402105893904574254763197682709 + }, + { + "variant_id": 0, + "value": 3613143053999770272842665473502706307602279676970981102529837756866990003067 + }, + { + "variant_id": 0, + "value": 6 + } + ], + "leaves": 7 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/insertion_test_case_2.json b/packages/utreexo/tests/data/insertion_test_case_2.json new file mode 100644 index 00000000..c96c9d58 --- /dev/null +++ b/packages/utreexo/tests/data/insertion_test_case_2.json @@ -0,0 +1,49 @@ +{ + "state": { + "roots": [], + "leaves": 0 + }, + "proof": { + "nodes": [], + "targets": [] + }, + "leaves_to_del": [], + "leaves_to_add": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14 + ], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 1010147253610699894986241683624609428739638206544914327400350896031110287324 + }, + { + "variant_id": 0, + "value": 2224391216833402212724735773212940252356536072547264452695587483243907176367 + }, + { + "variant_id": 0, + "value": 3009277733733429566191908933097273596911357184294896938062356457901603258437 + }, + { + "variant_id": 0, + "value": 14 + } + ], + "leaves": 15 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/insertion_test_case_3.json b/packages/utreexo/tests/data/insertion_test_case_3.json new file mode 100644 index 00000000..6e326fe5 --- /dev/null +++ b/packages/utreexo/tests/data/insertion_test_case_3.json @@ -0,0 +1,237 @@ +{ + "state": { + "roots": [], + "leaves": 0 + }, + "proof": { + "nodes": [], + "targets": [] + }, + "leaves_to_del": [], + "leaves_to_add": [ + 70, + 13, + 55, + 152, + 74, + 33, + 39, + 122, + 252, + 53, + 224, + 211, + 11, + 25, + 122, + 14, + 191, + 152, + 115, + 205, + 160, + 163, + 90, + 191, + 199, + 242, + 216, + 32, + 141, + 6, + 200, + 109, + 211, + 53, + 72, + 250, + 108, + 163, + 224, + 90, + 17, + 25, + 92, + 254, + 172, + 211, + 26, + 231, + 254, + 159, + 183, + 180, + 135, + 131, + 194, + 83, + 207, + 158, + 226, + 49, + 138, + 136, + 73, + 143, + 105, + 164, + 50, + 58, + 94, + 168, + 90, + 128, + 132, + 238, + 168, + 47, + 153, + 20, + 90, + 106, + 113, + 168, + 27, + 136, + 206, + 3, + 117, + 87, + 213, + 48, + 104, + 7, + 59, + 167, + 164, + 161, + 151, + 11, + 63, + 145, + 61, + 24, + 40, + 231, + 49, + 78, + 86, + 52, + 208, + 35, + 97, + 15, + 215, + 238, + 255, + 227, + 180, + 226, + 18, + 223, + 126, + 157, + 123, + 81, + 149, + 46, + 133, + 132, + 173, + 190, + 87, + 227, + 139, + 199, + 209, + 17, + 210, + 112, + 204, + 177, + 71, + 195, + 56, + 23, + 67, + 15, + 226, + 97, + 62, + 7, + 235, + 63, + 200, + 140, + 104, + 4, + 130, + 47, + 168, + 33, + 122, + 118, + 169, + 129, + 20, + 186, + 121, + 114, + 107, + 79, + 215, + 226, + 45, + 0, + 108, + 43, + 53, + 218, + 252, + 71, + 176, + 54, + 93, + 0, + 168, + 238, + 209, + 41, + 198, + 111, + 235, + 215, + 216, + 60, + 135, + 230, + 205, + 177, + 102 + ], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 2672466713874524096706188653290465293041789171537063033475721019051021709650 + }, + { + "variant_id": 0, + "value": 800167443309767050337371835372566580588382650816996663888846566248424467770 + }, + { + "variant_id": 0, + "value": 2341279804388063006376825986227464425832324574402694026157731031180941806793 + }, + { + "variant_id": 0, + "value": 3599240998874953227291885504793759279722011806456495621536520426822519234449 + }, + { + "variant_id": 0, + "value": 102 + } + ], + "leaves": 199 + } +} \ No newline at end of file From 7d4f01a90a835ea3dec2b3fc41ef385b0e70a336 Mon Sep 17 00:00:00 2001 From: Michael Zaikin Date: Fri, 18 Oct 2024 20:12:34 +0100 Subject: [PATCH 3/3] More test cases ported --- packages/utreexo/Scarb.toml | 2 +- .../tests/data/cached_proof_test_case_0.json | 44 ++++++++++++ .../tests/data/cached_proof_test_case_1.json | 40 +++++++++++ .../tests/data/cached_proof_test_case_2.json | 38 ++++++++++ .../tests/data/cached_proof_test_case_3.json | 49 +++++++++++++ .../tests/data/cached_proof_test_case_4.json | 32 +++++++++ .../tests/data/cached_proof_test_case_5.json | 36 ++++++++++ .../tests/data/cached_proof_test_case_6.json | 42 +++++++++++ .../tests/data/cached_proof_test_case_7.json | 41 +++++++++++ packages/utreexo/tests/data/ignore | 16 +++++ .../tests/data/update_data_test_case_0.json | 26 +++++++ .../tests/data/update_data_test_case_1.json | 44 ++++++++++++ .../tests/data/update_data_test_case_2.json | 46 ++++++++++++ .../tests/data/update_data_test_case_3.json | 35 ++++++++++ .../tests/data/update_data_test_case_4.json | 43 ++++++++++++ .../tests/data/update_data_test_case_5.json | 49 +++++++++++++ .../tests/data/update_data_test_case_6.json | 59 ++++++++++++++++ .../tests/data/update_data_test_case_7.json | 70 +++++++++++++++++++ 18 files changed, 711 insertions(+), 1 deletion(-) create mode 100644 packages/utreexo/tests/data/cached_proof_test_case_0.json create mode 100644 packages/utreexo/tests/data/cached_proof_test_case_1.json create mode 100644 packages/utreexo/tests/data/cached_proof_test_case_2.json create mode 100644 packages/utreexo/tests/data/cached_proof_test_case_3.json create mode 100644 packages/utreexo/tests/data/cached_proof_test_case_4.json create mode 100644 packages/utreexo/tests/data/cached_proof_test_case_5.json create mode 100644 packages/utreexo/tests/data/cached_proof_test_case_6.json create mode 100644 packages/utreexo/tests/data/cached_proof_test_case_7.json create mode 100644 packages/utreexo/tests/data/update_data_test_case_0.json create mode 100644 packages/utreexo/tests/data/update_data_test_case_1.json create mode 100644 packages/utreexo/tests/data/update_data_test_case_2.json create mode 100644 packages/utreexo/tests/data/update_data_test_case_3.json create mode 100644 packages/utreexo/tests/data/update_data_test_case_4.json create mode 100644 packages/utreexo/tests/data/update_data_test_case_5.json create mode 100644 packages/utreexo/tests/data/update_data_test_case_6.json create mode 100644 packages/utreexo/tests/data/update_data_test_case_7.json diff --git a/packages/utreexo/Scarb.toml b/packages/utreexo/Scarb.toml index b6836d01..6b28a9b6 100644 --- a/packages/utreexo/Scarb.toml +++ b/packages/utreexo/Scarb.toml @@ -12,4 +12,4 @@ cairo_test.workspace = true [scripts] # TODO: cairo lint lint = "scarb fmt" -test = "scarb cairo-test && ../../scripts/data/integration_tests.sh" \ No newline at end of file +test = "scarb cairo-test && scarb build && ../../scripts/data/integration_tests.sh" \ No newline at end of file diff --git a/packages/utreexo/tests/data/cached_proof_test_case_0.json b/packages/utreexo/tests/data/cached_proof_test_case_0.json new file mode 100644 index 00000000..900432b4 --- /dev/null +++ b/packages/utreexo/tests/data/cached_proof_test_case_0.json @@ -0,0 +1,44 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1010147253610699894986241683624609428739638206544914327400350896031110287324 + } + ], + "leaves": 8 + }, + "proof": { + "nodes": [ + 359114454570462701179676018441683730149326686283278794303413350979946254235, + 2920447154653459698578961030005574439730780339384884329678783637696763668074 + ], + "targets": [ + 0, + 1 + ] + }, + "leaves_to_del": [], + "leaves_to_add": [ + 20, + 21, + 22 + ], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 1566871981950648467436488177931532718969053285649065514773309084960104998335 + }, + { + "variant_id": 0, + "value": 2027894189441199778894566861688137166317361494271272989413883987271219468103 + }, + { + "variant_id": 0, + "value": 22 + } + ], + "leaves": 11 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/cached_proof_test_case_1.json b/packages/utreexo/tests/data/cached_proof_test_case_1.json new file mode 100644 index 00000000..bfa464f9 --- /dev/null +++ b/packages/utreexo/tests/data/cached_proof_test_case_1.json @@ -0,0 +1,40 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1010147253610699894986241683624609428739638206544914327400350896031110287324 + } + ], + "leaves": 8 + }, + "proof": { + "nodes": [ + 5, + 359114454570462701179676018441683730149326686283278794303413350979946254235, + 2476911194812244264213538976037850550079366744233323933541290896048104351430 + ], + "targets": [ + 0, + 1, + 4 + ] + }, + "leaves_to_del": [], + "leaves_to_add": [ + 8 + ], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 1684605927563332242289960912912659092722359194724270059585709599845081574916 + }, + { + "variant_id": 0, + "value": 8 + } + ], + "leaves": 9 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/cached_proof_test_case_2.json b/packages/utreexo/tests/data/cached_proof_test_case_2.json new file mode 100644 index 00000000..41447912 --- /dev/null +++ b/packages/utreexo/tests/data/cached_proof_test_case_2.json @@ -0,0 +1,38 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1010147253610699894986241683624609428739638206544914327400350896031110287324 + } + ], + "leaves": 8 + }, + "proof": { + "nodes": [ + 5, + 2476911194812244264213538976037850550079366744233323933541290896048104351430, + 1229371501456391789924831928153470943555736434402105893904574254763197682709 + ], + "targets": [ + 4 + ] + }, + "leaves_to_del": [], + "leaves_to_add": [ + 8 + ], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 2543242248923883501889459312371029730658374096283188732149186252132178387348 + }, + { + "variant_id": 0, + "value": 8 + } + ], + "leaves": 9 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/cached_proof_test_case_3.json b/packages/utreexo/tests/data/cached_proof_test_case_3.json new file mode 100644 index 00000000..cc1b7f10 --- /dev/null +++ b/packages/utreexo/tests/data/cached_proof_test_case_3.json @@ -0,0 +1,49 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1010147253610699894986241683624609428739638206544914327400350896031110287324 + }, + { + "variant_id": 0, + "value": 2224391216833402212724735773212940252356536072547264452695587483243907176367 + }, + { + "variant_id": 0, + "value": 3009277733733429566191908933097273596911357184294896938062356457901603258437 + } + ], + "leaves": 14 + }, + "proof": { + "nodes": [ + 1229371501456391789924831928153470943555736434402105893904574254763197682709 + ], + "targets": [ + 4, + 5, + 6, + 7 + ] + }, + "leaves_to_del": [], + "leaves_to_add": [], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 1229371501456391789924831928153470943555736434402105893904574254763197682709 + }, + { + "variant_id": 0, + "value": 2224391216833402212724735773212940252356536072547264452695587483243907176367 + }, + { + "variant_id": 0, + "value": 3009277733733429566191908933097273596911357184294896938062356457901603258437 + } + ], + "leaves": 14 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/cached_proof_test_case_4.json b/packages/utreexo/tests/data/cached_proof_test_case_4.json new file mode 100644 index 00000000..bb15fe7c --- /dev/null +++ b/packages/utreexo/tests/data/cached_proof_test_case_4.json @@ -0,0 +1,32 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1010147253610699894986241683624609428739638206544914327400350896031110287324 + } + ], + "leaves": 8 + }, + "proof": { + "nodes": [ + 1, + 359114454570462701179676018441683730149326686283278794303413350979946254235, + 2920447154653459698578961030005574439730780339384884329678783637696763668074 + ], + "targets": [ + 0 + ] + }, + "leaves_to_del": [], + "leaves_to_add": [], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 1390204248042318895134432832714975405388923780014300346567243638667265469832 + } + ], + "leaves": 8 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/cached_proof_test_case_5.json b/packages/utreexo/tests/data/cached_proof_test_case_5.json new file mode 100644 index 00000000..1092cfe1 --- /dev/null +++ b/packages/utreexo/tests/data/cached_proof_test_case_5.json @@ -0,0 +1,36 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 313455620397951742217570265587996884547193273693570485296736643582499576122 + } + ], + "leaves": 32 + }, + "proof": { + "nodes": [ + 2, + 7, + 0, + 5, + 2761512008972594569397269935073111909677583342716463654277011780899949492239, + 226102115184302870269476346253132176384258397936010785698544099242811230814 + ], + "targets": [ + 3, + 6 + ] + }, + "leaves_to_del": [], + "leaves_to_add": [], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 3131467188211843618406071253624707105300726788230916916663054629597474049049 + } + ], + "leaves": 32 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/cached_proof_test_case_6.json b/packages/utreexo/tests/data/cached_proof_test_case_6.json new file mode 100644 index 00000000..fd5a2ab0 --- /dev/null +++ b/packages/utreexo/tests/data/cached_proof_test_case_6.json @@ -0,0 +1,42 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1347517334382637346943874592983838377757642136153945464698821274069571697599 + }, + { + "variant_id": 0, + "value": 11 + } + ], + "leaves": 12 + }, + "proof": { + "nodes": [ + 2, + 7, + 0, + 5 + ], + "targets": [ + 3, + 6 + ] + }, + "leaves_to_del": [], + "leaves_to_add": [], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 2876516617194610423170642440651301959278853848182275138875020734413818300640 + }, + { + "variant_id": 0, + "value": 11 + } + ], + "leaves": 12 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/cached_proof_test_case_7.json b/packages/utreexo/tests/data/cached_proof_test_case_7.json new file mode 100644 index 00000000..127aa66d --- /dev/null +++ b/packages/utreexo/tests/data/cached_proof_test_case_7.json @@ -0,0 +1,41 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1229371501456391789924831928153470943555736434402105893904574254763197682709 + }, + { + "variant_id": 0, + "value": 3613143053999770272842665473502706307602279676970981102529837756866990003067 + } + ], + "leaves": 6 + }, + "proof": { + "nodes": [], + "targets": [ + 4, + 5 + ] + }, + "leaves_to_del": [], + "leaves_to_add": [ + 6, + 7, + 8 + ], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 3277837308220011616970132764433061499794215809794714884171345555786254766333 + }, + { + "variant_id": 0, + "value": 8 + } + ], + "leaves": 9 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/ignore b/packages/utreexo/tests/data/ignore index 009ac891..0e766097 100644 --- a/packages/utreexo/tests/data/ignore +++ b/packages/utreexo/tests/data/ignore @@ -7,3 +7,19 @@ insertion_test_case_0.json insertion_test_case_1.json insertion_test_case_2.json insertion_test_case_3.json +update_data_test_case_0.json +update_data_test_case_1.json +update_data_test_case_2.json +update_data_test_case_3.json +update_data_test_case_4.json +update_data_test_case_5.json +update_data_test_case_6.json +update_data_test_case_7.json +cached_proof_test_case_0.json +cached_proof_test_case_1.json +cached_proof_test_case_2.json +cached_proof_test_case_3.json +cached_proof_test_case_4.json +cached_proof_test_case_5.json +cached_proof_test_case_6.json +cached_proof_test_case_7.json diff --git a/packages/utreexo/tests/data/update_data_test_case_0.json b/packages/utreexo/tests/data/update_data_test_case_0.json new file mode 100644 index 00000000..383e9b1d --- /dev/null +++ b/packages/utreexo/tests/data/update_data_test_case_0.json @@ -0,0 +1,26 @@ +{ + "state": { + "roots": [], + "leaves": 0 + }, + "proof": { + "nodes": [], + "targets": [] + }, + "leaves_to_del": [], + "leaves_to_add": [ + 0, + 1, + 2, + 3 + ], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 1229371501456391789924831928153470943555736434402105893904574254763197682709 + } + ], + "leaves": 4 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/update_data_test_case_1.json b/packages/utreexo/tests/data/update_data_test_case_1.json new file mode 100644 index 00000000..edb0542f --- /dev/null +++ b/packages/utreexo/tests/data/update_data_test_case_1.json @@ -0,0 +1,44 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1229371501456391789924831928153470943555736434402105893904574254763197682709 + }, + { + "variant_id": 0, + "value": 3613143053999770272842665473502706307602279676970981102529837756866990003067 + } + ], + "leaves": 6 + }, + "proof": { + "nodes": [], + "targets": [] + }, + "leaves_to_del": [], + "leaves_to_add": [ + 0, + 1, + 2, + 3, + 4 + ], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 945641959479884596276280359010537033900847747393306152653491159565696171999 + }, + { + "variant_id": 0, + "value": 359114454570462701179676018441683730149326686283278794303413350979946254235 + }, + { + "variant_id": 0, + "value": 4 + } + ], + "leaves": 11 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/update_data_test_case_2.json b/packages/utreexo/tests/data/update_data_test_case_2.json new file mode 100644 index 00000000..767ee6f4 --- /dev/null +++ b/packages/utreexo/tests/data/update_data_test_case_2.json @@ -0,0 +1,46 @@ +{ + "state": { + "roots": [ + { + "variant_id": 1 + } + ], + "leaves": 4 + }, + "proof": { + "nodes": [], + "targets": [] + }, + "leaves_to_del": [], + "leaves_to_add": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15 + ], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 3345594299512021644072616344838868764004427464837806409770123729363159548676 + }, + { + "variant_id": 0, + "value": 1813826121834271504980511192245059557593697196840757755209576674667633130596 + } + ], + "leaves": 20 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/update_data_test_case_3.json b/packages/utreexo/tests/data/update_data_test_case_3.json new file mode 100644 index 00000000..21c815ce --- /dev/null +++ b/packages/utreexo/tests/data/update_data_test_case_3.json @@ -0,0 +1,35 @@ +{ + "state": { + "roots": [ + { + "variant_id": 1 + } + ], + "leaves": 4 + }, + "proof": { + "nodes": [], + "targets": [] + }, + "leaves_to_del": [], + "leaves_to_add": [ + 0, + 1, + 2, + 3, + 4 + ], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 1229371501456391789924831928153470943555736434402105893904574254763197682709 + }, + { + "variant_id": 0, + "value": 4 + } + ], + "leaves": 9 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/update_data_test_case_4.json b/packages/utreexo/tests/data/update_data_test_case_4.json new file mode 100644 index 00000000..8f60059d --- /dev/null +++ b/packages/utreexo/tests/data/update_data_test_case_4.json @@ -0,0 +1,43 @@ +{ + "state": { + "roots": [ + { + "variant_id": 1 + }, + { + "variant_id": 0, + "value": 3613143053999770272842665473502706307602279676970981102529837756866990003067 + } + ], + "leaves": 6 + }, + "proof": { + "nodes": [], + "targets": [] + }, + "leaves_to_del": [], + "leaves_to_add": [ + 0, + 1, + 2, + 3, + 4 + ], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 710951542035212751640896167671035614040074629013281458212474885071479683933 + }, + { + "variant_id": 0, + "value": 359114454570462701179676018441683730149326686283278794303413350979946254235 + }, + { + "variant_id": 0, + "value": 4 + } + ], + "leaves": 11 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/update_data_test_case_5.json b/packages/utreexo/tests/data/update_data_test_case_5.json new file mode 100644 index 00000000..de153bb3 --- /dev/null +++ b/packages/utreexo/tests/data/update_data_test_case_5.json @@ -0,0 +1,49 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 1229371501456391789924831928153470943555736434402105893904574254763197682709 + }, + { + "variant_id": 0, + "value": 3613143053999770272842665473502706307602279676970981102529837756866990003067 + } + ], + "leaves": 6 + }, + "proof": { + "nodes": [], + "targets": [ + 0, + 1, + 2, + 3 + ] + }, + "leaves_to_del": [], + "leaves_to_add": [ + 0, + 1, + 2, + 3, + 4 + ], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 710951542035212751640896167671035614040074629013281458212474885071479683933 + }, + { + "variant_id": 0, + "value": 359114454570462701179676018441683730149326686283278794303413350979946254235 + }, + { + "variant_id": 0, + "value": 4 + } + ], + "leaves": 11 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/update_data_test_case_6.json b/packages/utreexo/tests/data/update_data_test_case_6.json new file mode 100644 index 00000000..f87dbb96 --- /dev/null +++ b/packages/utreexo/tests/data/update_data_test_case_6.json @@ -0,0 +1,59 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 2778277074578782368986165095004756321440748237082580104984033528445453379385 + } + ], + "leaves": 16 + }, + "proof": { + "nodes": [ + 1, + 3, + 6, + 13, + 15, + 3613143053999770272842665473502706307602279676970981102529837756866990003067, + 2224391216833402212724735773212940252356536072547264452695587483243907176367 + ], + "targets": [ + 0, + 2, + 7, + 12, + 14 + ] + }, + "leaves_to_del": [], + "leaves_to_add": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 2102892054616389011881208214050142511704491869943120734708357879941856940935 + }, + { + "variant_id": 0, + "value": 1010147253610699894986241683624609428739638206544914327400350896031110287324 + }, + { + "variant_id": 0, + "value": 3115762988631556491925147498418117978906005591291390166955707455104569660364 + } + ], + "leaves": 26 + } +} \ No newline at end of file diff --git a/packages/utreexo/tests/data/update_data_test_case_7.json b/packages/utreexo/tests/data/update_data_test_case_7.json new file mode 100644 index 00000000..59c755ad --- /dev/null +++ b/packages/utreexo/tests/data/update_data_test_case_7.json @@ -0,0 +1,70 @@ +{ + "state": { + "roots": [ + { + "variant_id": 0, + "value": 2778277074578782368986165095004756321440748237082580104984033528445453379385 + }, + { + "variant_id": 0, + "value": 16 + } + ], + "leaves": 17 + }, + "proof": { + "nodes": [ + 1, + 3, + 6, + 11, + 13, + 3613143053999770272842665473502706307602279676970981102529837756866990003067, + 3115762988631556491925147498418117978906005591291390166955707455104569660364 + ], + "targets": [ + 0, + 2, + 7, + 10, + 12, + 14, + 15, + 16 + ] + }, + "leaves_to_del": [], + "leaves_to_add": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "expected_state": { + "roots": [ + { + "variant_id": 0, + "value": 3466041587656626467296475334329187679944381739399576751832382082629226859694 + }, + { + "variant_id": 0, + "value": 1885941099383556298602794424812266815860231064548932622718476220765955656011 + }, + { + "variant_id": 0, + "value": 1119257953635074008975413131841626821099834104223305347673121814435521957776 + }, + { + "variant_id": 0, + "value": 9 + } + ], + "leaves": 27 + } +} \ No newline at end of file