Skip to content

Commit

Permalink
testing: updated integration tests to assert delta operation values f…
Browse files Browse the repository at this point in the history
…or store max int64
  • Loading branch information
colindickson committed Jan 26, 2023
1 parent 40c1fdf commit f8e4481
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func TestStoreDeletePrefix(t *testing.T) {

func TestAllAssertions(t *testing.T) {
// Relies on `assert_all_test` having modInit == 1, so
run := newTestRun(20, 31, 31, "assert_all_test")
run := newTestRun(1, 31, 31, "assert_all_test")

require.NoError(t, run.Run(t))

Expand Down
20 changes: 20 additions & 0 deletions test/testdata/simple_substreams/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ use substreams::{
StoreSetProto,
},
};
use substreams::pb::substreams::store_delta::Operation;
use substreams::pb::substreams::store_delta::Operation::{Create, Update};

use crate::pb::test;
use crate::pb::test::Block;
Expand Down Expand Up @@ -275,10 +277,22 @@ impl generated::substreams::SubstreamsTrait for generated::substreams::Substream
let delta_0 = deltas.deltas.get(0).unwrap();
assert(block.number, 0, delta_0.old_value);
assert(block.number, i64::MAX, delta_0.new_value);
match delta_0.operation {
Create => {}
_ => {
panic!("expected Create, got {:?}", delta_0.operation);
}
}

let delta_1 = deltas.deltas.get(1).unwrap();
assert(block.number, i64::MAX, delta_1.old_value);
assert(block.number, i64::MAX, delta_1.new_value);
match delta_1.operation {
Update => {}
_ => {
panic!("expected Update, got {:?}", delta_1.operation);
}
}
}
_ => {
if deltas.deltas.len() != 1 {
Expand All @@ -288,6 +302,12 @@ impl generated::substreams::SubstreamsTrait for generated::substreams::Substream
let delta_0 = deltas.deltas.get(0).unwrap();
assert(block.number, i64::MAX, delta_0.old_value);
assert(block.number, i64::MAX, delta_0.new_value);
match delta_0.operation {
Update => {}
_ => {
panic!("expected Update, got {:?}", delta_0.operation);
}
}
}
}

Expand Down
Binary file modified test/testdata/substreams-test-v0.1.0.spkg
Binary file not shown.

0 comments on commit f8e4481

Please sign in to comment.