Skip to content

Commit

Permalink
add another test, bump changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
sduchesneau committed Sep 19, 2024
1 parent 356d34d commit 7c74e5f
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docs/release-notes/change-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
## v1.10.5

* Fixed an(other) issue where multiple stores running on the same stage with different initialBlocks will fail to proress
* Fixed an(other) issue where multiple stores running on the same stage with different initialBlocks will fail to proress (and hang)

## v1.10.4

Expand Down
25 changes: 16 additions & 9 deletions test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func TestOneStoreOneMap(t *testing.T) {
}
require.NoError(t, err)

mapOutput := run.MapOutput("assert_test_store_add_i64")
mapOutput := run.MapOutputString("assert_test_store_add_i64")
assert.Contains(t, mapOutput, `assert_test_store_add_i64: 0801`)

assert.Equal(t, test.expectedResponseCount, strings.Count(mapOutput, "\n"))
Expand Down Expand Up @@ -414,16 +414,23 @@ func TestMultipleStoresDifferentStartBlocks(t *testing.T) {
func TestMultipleStoresUnalignedStartBlocksDevMode(t *testing.T) {
manifest.TestUseSimpleHash = true
// dev mode
run2 := newTestRun(t, 23, 999, 30, 0, "multi_store_different_23", "./testdata/complex_substreams/complex-substreams-v0.1.0.spkg")
require.NoError(t, run2.Run(t, "dev_mode"))
fmt.Println(run2.MapOutput("multi_store_different_23"))
run := newTestRun(t, 23, 999, 30, 0, "multi_store_different_23", "./testdata/complex_substreams/complex-substreams-v0.1.0.spkg")
require.NoError(t, run.Run(t, "dev_mode"))
outs := run.MapOutput("multi_store_different_23")
// ensure that the 20->22 block range is processed by the "set_sum_store_init_0" store
assert.Contains(t, string(outs[23]), "store2:sum:276") // 1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23 = 276
assert.Contains(t, string(outs[24]), "store2:sum:300") // 276+24 ...
}
func TestMultipleStoresUnalignedStartBlocksProdMode(t *testing.T) {
manifest.TestUseSimpleHash = true
run2 := newTestRun(t, 23, 999, 30, 0, "multi_store_different_23", "./testdata/complex_substreams/complex-substreams-v0.1.0.spkg")
run2.ProductionMode = true
require.NoError(t, run2.Run(t, "prod_mode"))
fmt.Println(run2.MapOutput("multi_store_different_23"))
run := newTestRun(t, 23, 999, 30, 0, "multi_store_different_23", "./testdata/complex_substreams/complex-substreams-v0.1.0.spkg")
run.ProductionMode = true
require.NoError(t, run.Run(t, "prod_mode"))

outs := run.MapOutput("multi_store_different_23")
// ensure that the 20->22 block range is processed by the "set_sum_store_init_0" store
assert.Contains(t, string(outs[23]), "store2:sum:276") // 1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23 = 276
assert.Contains(t, string(outs[24]), "store2:sum:300") // 276+24 ...
}

func TestStoreDeletePrefix(t *testing.T) {
Expand Down Expand Up @@ -477,7 +484,7 @@ func Test_WASMBindgenShims(t *testing.T) {

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

mapOutput := run.MapOutput("map_block")
mapOutput := run.MapOutputString("map_block")
fmt.Println(mapOutput)

}
Expand Down
26 changes: 25 additions & 1 deletion test/runnable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,31 @@ func (f *testRun) Logs() (out []string) {
return
}

func (f *testRun) MapOutput(modName string) string {
func (f *testRun) MapOutput(modName string) map[uint64][]byte {

moduleOutputs := make(map[uint64][]byte)
for _, response := range f.Responses {
switch r := response.Message.(type) {
case *pbsubstreamsrpc.Response_BlockScopedData:
for _, output := range r.BlockScopedData.AllModuleOutputs() {
if output.Name() != modName {
continue
}
if !output.IsMap() {
continue
}
mapout := output.MapOutput.GetMapOutput()
if mapout == nil {
continue
}
moduleOutputs[r.BlockScopedData.Clock.Number] = mapout.Value
}
}
}
return moduleOutputs
}

func (f *testRun) MapOutputString(modName string) string {
var moduleOutputs []string
for _, response := range f.Responses {
switch r := response.Message.(type) {
Expand Down
Binary file modified test/testdata/complex_substreams/complex-substreams-v0.1.0.spkg
Binary file not shown.
23 changes: 21 additions & 2 deletions test/testdata/complex_substreams/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,28 @@ fn multi_store_different_40(first_store: store::Deltas<DeltaInt64>, second_store

#[substreams::handlers::map]
fn multi_store_different_23(first_store: store::Deltas<DeltaInt64>, second_store: store::Deltas<DeltaString>) -> Result<test::Block, Error> {
let mut store1_value: i64 = 0;
first_store
.deltas
.iter()
.for_each(|delta| match delta.key.as_str() {
"block_counter" => store1_value = delta.new_value,
x => panic!("unhandled key {}", x),
});

let mut store2_value: String = "".to_string();
second_store
.deltas
.iter()
.for_each(|delta| match delta.key.as_str() {
"sum" => store2_value = delta.new_value.clone(),
x => panic!("unhandled key {}", x),
});


Ok(test::Block {
id: "hehehehe".to_string(),
number: 5,
id: "store2:".to_string()+&store2_value.to_string(),
number: store1_value as u64,
})
}

Expand Down

0 comments on commit 7c74e5f

Please sign in to comment.