Skip to content

Commit

Permalink
add tests to simulate issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sduchesneau committed Sep 4, 2024
1 parent ecaaa2e commit 8148ccf
Show file tree
Hide file tree
Showing 10 changed files with 507 additions and 71 deletions.
2 changes: 1 addition & 1 deletion test/testdata/complex_substreams/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ gui: build

.PHONY: protogen
protogen:
substreams protogen ./substreams.yaml --exclude-paths="sf/substreams,google"
substreams protogen ./substreams.yaml --exclude-paths="sf/substreams/sink,sf/substreams/rpc,google"

.PHONY: pack
pack: build
Expand Down
Binary file modified test/testdata/complex_substreams/complex-substreams-v0.1.0.spkg
Binary file not shown.
2 changes: 1 addition & 1 deletion test/testdata/complex_substreams/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.65"
channel = "1.80"
components = [ "rustfmt" ]
targets = [ "wasm32-unknown-unknown" ]
17 changes: 10 additions & 7 deletions test/testdata/complex_substreams/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
mod pb;

use crate::pb::test;
use crate::pb::keys;
use substreams::errors::Error;
use crate::pb::sf::substreams::v1::test;
use substreams::prelude::*;
use substreams::store::{StoreAdd, StoreSetSum, StoreSetSumInt64};
use substreams::store::StoreNew;
use crate::pb::test::Block;
use substreams::{store, Hex};
use crate::pb::sf::substreams::index::v1::Keys;
use substreams::store;
use log::log;
use substreams::errors::Error;


#[substreams::handlers::map]
fn index_init_60(blk: test::Block) -> Result<keys::Keys, substreams::errors::Error> {
let mut keys = keys::Keys::default();
fn index_init_60(blk: test::Block) -> Result<Keys, Error> {
let mut keys = Keys::default();
if blk.number % 2 == 0 {
keys.keys.push("even".to_string());
} else {
Expand All @@ -28,6 +27,10 @@ fn map_using_index_init_70(blk: test::Block) -> Result<test::Boolean, Error> {
Ok(test::Boolean { result: true })
}

#[substreams::handlers::map]
fn map_hybrid_input_clock_70(_clock: pb::sf::substreams::v1::Clock, input: test::Boolean) -> Result<test::Boolean, Error> {
Ok(test::Boolean { result: input.result })
}

#[substreams::handlers::store]
fn first_store_init_20(block: test::Block, first_store: StoreAddInt64) {
Expand Down
32 changes: 25 additions & 7 deletions test/testdata/complex_substreams/src/pb/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
#[allow(dead_code)]
#[path = "./sf.substreams.v1.test.rs"]
pub mod test;

#[allow(dead_code)]
#[path = "./sf.substreams.index.v1.rs"]
pub mod keys;
// @generated
pub mod sf {
// @@protoc_insertion_point(attribute:sf.substreams)
pub mod substreams {
include!("sf.substreams.rs");
// @@protoc_insertion_point(sf.substreams)
pub mod index {
// @@protoc_insertion_point(attribute:sf.substreams.index.v1)
pub mod v1 {
include!("sf.substreams.index.v1.rs");
// @@protoc_insertion_point(sf.substreams.index.v1)
}
}
// @@protoc_insertion_point(attribute:sf.substreams.v1)
pub mod v1 {
include!("sf.substreams.v1.rs");
// @@protoc_insertion_point(sf.substreams.v1)
// @@protoc_insertion_point(attribute:sf.substreams.v1.test)
pub mod test {
include!("sf.substreams.v1.test.rs");
// @@protoc_insertion_point(sf.substreams.v1.test)
}
}
}
}
14 changes: 14 additions & 0 deletions test/testdata/complex_substreams/src/pb/sf.substreams.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// @generated
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct FieldOptions {
/// this option informs the `substreams pack` command that it should treat the corresponding manifest value as a path to a file, putting its content as bytes in this field.
/// must be applied to a `bytes` or `string` field
#[prost(bool, tag="1")]
pub load_from_file: bool,
/// this option informs the `substreams pack` command that it should treat the corresponding manifest value as a path to a folder, zipping its content and putting the zip content as bytes in this field.
/// must be applied to a `bytes` field
#[prost(bool, tag="2")]
pub zip_from_folder: bool,
}
// @@protoc_insertion_point(module)
Loading

0 comments on commit 8148ccf

Please sign in to comment.