Skip to content

Commit 87c802a

Browse files
committed
store/test-store: test more types for DataSource context in manifest
1 parent e40526f commit 87c802a

File tree

1 file changed

+67
-8
lines changed

1 file changed

+67
-8
lines changed

store/test-store/tests/chain/ethereum/manifest.rs

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
use std::collections::HashMap;
22
use std::num::NonZeroU32;
3+
use std::str::FromStr;
34
use std::sync::Arc;
45
use std::time::Duration;
56

67
use graph::blockchain::DataSource;
8+
use graph::data::store::scalar::Bytes;
79
use graph::data::store::Value;
810
use graph::data::subgraph::schema::SubgraphError;
911
use graph::data::subgraph::{SPEC_VERSION_0_0_4, SPEC_VERSION_0_0_7, SPEC_VERSION_0_0_8};
1012
use graph::data_source::offchain::OffchainDataSourceKind;
1113
use graph::data_source::DataSourceTemplate;
1214
use graph::entity;
1315
use graph::prelude::{
14-
anyhow, async_trait, serde_yaml, tokio, DeploymentHash, Link, Logger, SubgraphManifest,
15-
SubgraphManifestValidationError, SubgraphStore, UnvalidatedSubgraphManifest,
16+
anyhow, async_trait, serde_yaml, tokio, BigDecimal, BigInt, DeploymentHash, Link, Logger,
17+
SubgraphManifest, SubgraphManifestValidationError, SubgraphStore, UnvalidatedSubgraphManifest,
1618
};
1719
use graph::{
1820
blockchain::NodeCapabilities as _,
@@ -387,10 +389,34 @@ dataSources:
387389
name: Factory
388390
network: mainnet
389391
context:
390-
foo:
392+
bool_example:
393+
type: Bool
394+
data: true
395+
int8_example:
396+
type: Int8
397+
data: 64
398+
big_decimal_example:
399+
type: BigDecimal
400+
data: 10.99
401+
bytes_example:
402+
type: Bytes
403+
data: \"0x68656c6c6f\"
404+
list_example:
405+
type: List
406+
data:
407+
- type: Int
408+
data: 1
409+
- type: Int
410+
data: 2
411+
- type: Int
412+
data: 3
413+
big_int_example:
414+
type: BigInt
415+
data: \"1000000000000000000000000\"
416+
string_example:
391417
type: String
392-
data: bar
393-
qux:
418+
data: \"bar\"
419+
int_example:
394420
type: Int
395421
data: 42
396422
source:
@@ -427,9 +453,42 @@ specVersion: 0.0.8
427453
let context = data_source.context.as_ref().clone().unwrap();
428454
let sorted = context.sorted();
429455

430-
assert_eq!(sorted.len(), 2);
431-
assert_eq!(sorted[0], ("foo".into(), Value::String("bar".into())));
432-
assert_eq!(sorted[1], ("qux".into(), Value::Int(42)));
456+
assert_eq!(sorted.len(), 8);
457+
assert_eq!(
458+
sorted[0],
459+
(
460+
"big_decimal_example".into(),
461+
Value::BigDecimal(BigDecimal::from(10.99))
462+
)
463+
);
464+
assert_eq!(
465+
sorted[1],
466+
(
467+
"big_int_example".into(),
468+
Value::BigInt(BigInt::from_str("1000000000000000000000000").unwrap())
469+
)
470+
);
471+
assert_eq!(sorted[2], ("bool_example".into(), Value::Bool(true)));
472+
assert_eq!(
473+
sorted[3],
474+
(
475+
"bytes_example".into(),
476+
Value::Bytes(Bytes::from_str("0x68656c6c6f").unwrap())
477+
)
478+
);
479+
assert_eq!(sorted[4], ("int8_example".into(), Value::Int8(64)));
480+
assert_eq!(sorted[5], ("int_example".into(), Value::Int(42)));
481+
assert_eq!(
482+
sorted[6],
483+
(
484+
"list_example".into(),
485+
Value::List(vec![Value::Int(1), Value::Int(2), Value::Int(3)])
486+
)
487+
);
488+
assert_eq!(
489+
sorted[7],
490+
("string_example".into(), Value::String("bar".into()))
491+
);
433492
}
434493

435494
#[tokio::test]

0 commit comments

Comments
 (0)