Skip to content

Commit 741507e

Browse files
committed
core, graphql, server, store: Update tests to optional block pointers
1 parent badaca7 commit 741507e

File tree

5 files changed

+28
-43
lines changed

5 files changed

+28
-43
lines changed

core/tests/interfaces.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn insert_and_query(
2727

2828
let logger = Logger::root(slog::Discard, o!());
2929

30-
let ops = SubgraphDeploymentEntity::new(&manifest, false, false, GENESIS_PTR.clone(), None)
30+
let ops = SubgraphDeploymentEntity::new(&manifest, false, false, None, None)
3131
.create_operations_replace(&subgraph_id)
3232
.into_iter()
3333
.map(|op| op.into())
@@ -48,7 +48,7 @@ fn insert_and_query(
4848
transact_entity_operations(
4949
&STORE,
5050
subgraph_id.clone(),
51-
BLOCK_ONE.clone(),
51+
GENESIS_PTR.clone(),
5252
insert_ops.collect::<Vec<_>>(),
5353
)?;
5454

graphql/tests/query.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::time::{Duration, Instant};
88

99
use graph::prelude::*;
1010
use graph_graphql::prelude::*;
11-
use test_store::{transact_entity_operations, BLOCK_ONE, GENESIS_PTR, STORE};
11+
use test_store::{transact_entity_operations, GENESIS_PTR, STORE};
1212

1313
lazy_static! {
1414
static ref TEST_SUBGRAPH_ID: SubgraphDeploymentId = {
@@ -77,7 +77,7 @@ fn insert_test_entities(store: &impl Store, id: SubgraphDeploymentId) {
7777
templates: vec![],
7878
};
7979

80-
let ops = SubgraphDeploymentEntity::new(&manifest, false, false, GENESIS_PTR.clone(), None)
80+
let ops = SubgraphDeploymentEntity::new(&manifest, false, false, None, None)
8181
.create_operations_replace(&id)
8282
.into_iter()
8383
.map(|op| op.into())
@@ -189,7 +189,7 @@ fn insert_test_entities(store: &impl Store, id: SubgraphDeploymentId) {
189189
transact_entity_operations(
190190
&STORE,
191191
id.clone(),
192-
BLOCK_ONE.clone(),
192+
GENESIS_PTR.clone(),
193193
insert_ops.collect::<Vec<_>>(),
194194
)
195195
.unwrap();

server/http/src/service.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,7 @@ mod tests {
479479
&manifest,
480480
false,
481481
false,
482-
EthereumBlockPointer {
483-
hash: H256::zero(),
484-
number: 0,
485-
},
482+
None,
486483
Some(EthereumBlockPointer {
487484
hash: H256::zero(),
488485
number: 0,
@@ -553,10 +550,7 @@ mod tests {
553550
&manifest,
554551
false,
555552
false,
556-
EthereumBlockPointer {
557-
hash: H256::zero(),
558-
number: 0,
559-
},
553+
None,
560554
Some(EthereumBlockPointer {
561555
hash: H256::zero(),
562556
number: 0,

server/http/tests/server.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,7 @@ mod test {
9797
&manifest,
9898
false,
9999
false,
100-
EthereumBlockPointer {
101-
hash: H256::zero(),
102-
number: 0,
103-
},
100+
None,
104101
Some(EthereumBlockPointer {
105102
hash: H256::zero(),
106103
number: 0,

store/postgres/tests/store.rs

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,8 @@ fn insert_test_data(store: Arc<DieselStore>) {
149149
};
150150

151151
// Create SubgraphDeploymentEntity
152-
let ops = SubgraphDeploymentEntity::new(
153-
&manifest,
154-
false,
155-
false,
156-
*TEST_BLOCK_0_PTR,
157-
Some(*TEST_BLOCK_0_PTR),
158-
)
159-
.create_operations(&*TEST_SUBGRAPH_ID);
152+
let ops = SubgraphDeploymentEntity::new(&manifest, false, false, None, Some(*TEST_BLOCK_0_PTR))
153+
.create_operations(&*TEST_SUBGRAPH_ID);
160154
store
161155
.create_subgraph_deployment(&TEST_SUBGRAPH_SCHEMA, ops)
162156
.unwrap();
@@ -174,7 +168,7 @@ fn insert_test_data(store: Arc<DieselStore>) {
174168
transact_entity_operations(
175169
&store,
176170
TEST_SUBGRAPH_ID.clone(),
177-
*TEST_BLOCK_1_PTR,
171+
*GENESIS_PTR,
178172
vec![test_entity_1],
179173
)
180174
.unwrap();
@@ -202,7 +196,7 @@ fn insert_test_data(store: Arc<DieselStore>) {
202196
transact_entity_operations(
203197
&store,
204198
TEST_SUBGRAPH_ID.clone(),
205-
*TEST_BLOCK_2_PTR,
199+
*TEST_BLOCK_1_PTR,
206200
vec![test_entity_2, test_entity_3_1],
207201
)
208202
.unwrap();
@@ -220,7 +214,7 @@ fn insert_test_data(store: Arc<DieselStore>) {
220214
transact_entity_operations(
221215
&store,
222216
TEST_SUBGRAPH_ID.clone(),
223-
*TEST_BLOCK_3_PTR,
217+
*TEST_BLOCK_2_PTR,
224218
vec![test_entity_3_2],
225219
)
226220
.unwrap();
@@ -307,7 +301,7 @@ fn delete_entity() {
307301
transact_entity_operations(
308302
&store,
309303
TEST_SUBGRAPH_ID.clone(),
310-
*TEST_BLOCK_4_PTR,
304+
*TEST_BLOCK_3_PTR,
311305
vec![EntityOperation::Remove {
312306
key: entity_key.clone(),
313307
}],
@@ -421,7 +415,7 @@ fn insert_entity() {
421415
transact_entity_operations(
422416
&store,
423417
TEST_SUBGRAPH_ID.clone(),
424-
*TEST_BLOCK_4_PTR,
418+
*TEST_BLOCK_3_PTR,
425419
vec![test_entity],
426420
)
427421
.unwrap();
@@ -469,7 +463,7 @@ fn update_existing() {
469463
transact_entity_operations(
470464
&store,
471465
TEST_SUBGRAPH_ID.clone(),
472-
*TEST_BLOCK_4_PTR,
466+
*TEST_BLOCK_3_PTR,
473467
vec![op],
474468
)
475469
.unwrap();
@@ -513,7 +507,7 @@ fn partially_update_existing() {
513507
transact_entity_operations(
514508
&store,
515509
TEST_SUBGRAPH_ID.clone(),
516-
*TEST_BLOCK_4_PTR,
510+
*TEST_BLOCK_3_PTR,
517511
vec![EntityOperation::Set {
518512
key: entity_key.clone(),
519513
data: partial_entity.clone(),
@@ -1510,8 +1504,8 @@ fn check_basic_revert(
15101504
store
15111505
.revert_block_operations(
15121506
TEST_SUBGRAPH_ID.clone(),
1513-
*TEST_BLOCK_3_PTR,
15141507
*TEST_BLOCK_2_PTR,
1508+
*TEST_BLOCK_1_PTR,
15151509
)
15161510
.unwrap();
15171511

@@ -1587,7 +1581,7 @@ fn revert_block_with_delete() {
15871581
transact_entity_operations(
15881582
&store,
15891583
TEST_SUBGRAPH_ID.clone(),
1590-
*TEST_BLOCK_4_PTR,
1584+
*TEST_BLOCK_3_PTR,
15911585
vec![EntityOperation::Remove { key: del_key }],
15921586
)
15931587
.unwrap();
@@ -1599,8 +1593,8 @@ fn revert_block_with_delete() {
15991593
store
16001594
.revert_block_operations(
16011595
TEST_SUBGRAPH_ID.clone(),
1602-
*TEST_BLOCK_4_PTR,
16031596
*TEST_BLOCK_3_PTR,
1597+
*TEST_BLOCK_2_PTR,
16041598
)
16051599
.unwrap();
16061600
assert_eq!(
@@ -1658,7 +1652,7 @@ fn revert_block_with_partial_update() {
16581652
transact_entity_operations(
16591653
&store,
16601654
TEST_SUBGRAPH_ID.clone(),
1661-
*TEST_BLOCK_4_PTR,
1655+
*TEST_BLOCK_3_PTR,
16621656
vec![EntityOperation::Set {
16631657
key: entity_key.clone(),
16641658
data: partial_entity.clone(),
@@ -1673,8 +1667,8 @@ fn revert_block_with_partial_update() {
16731667
store
16741668
.revert_block_operations(
16751669
TEST_SUBGRAPH_ID.clone(),
1676-
*TEST_BLOCK_4_PTR,
16771670
*TEST_BLOCK_3_PTR,
1671+
*TEST_BLOCK_2_PTR,
16781672
)
16791673
.unwrap();
16801674
assert_eq!(count, get_entity_count(store.clone(), &TEST_SUBGRAPH_ID));
@@ -1786,7 +1780,7 @@ fn revert_block_with_dynamic_data_source_operations() {
17861780
ops.extend(dynamic_ds.write_entity_operations("dynamic-data-source"));
17871781

17881782
// Add user and dynamic data source to the store
1789-
transact_entity_operations(&store, TEST_SUBGRAPH_ID.clone(), *TEST_BLOCK_4_PTR, ops)
1783+
transact_entity_operations(&store, TEST_SUBGRAPH_ID.clone(), *TEST_BLOCK_3_PTR, ops)
17901784
.unwrap();
17911785

17921786
// Verify that the user is no longer the original
@@ -1815,8 +1809,8 @@ fn revert_block_with_dynamic_data_source_operations() {
18151809
store
18161810
.revert_block_operations(
18171811
TEST_SUBGRAPH_ID.clone(),
1818-
*TEST_BLOCK_4_PTR,
18191812
*TEST_BLOCK_3_PTR,
1813+
*TEST_BLOCK_2_PTR,
18201814
)
18211815
.expect("revert block operations failed unexpectedly");
18221816

@@ -1909,7 +1903,7 @@ fn entity_changes_are_fired_and_forwarded_to_subscriptions() {
19091903
&manifest,
19101904
false,
19111905
false,
1912-
*TEST_BLOCK_0_PTR,
1906+
Some(*TEST_BLOCK_0_PTR),
19131907
Some(*TEST_BLOCK_0_PTR),
19141908
)
19151909
.create_operations(&subgraph_id);
@@ -2075,7 +2069,7 @@ fn throttle_subscription_delivers() {
20752069
transact_entity_operations(
20762070
&store,
20772071
TEST_SUBGRAPH_ID.clone(),
2078-
*TEST_BLOCK_4_PTR,
2072+
*TEST_BLOCK_3_PTR,
20792073
vec![user4],
20802074
)
20812075
.unwrap();
@@ -2124,7 +2118,7 @@ fn throttle_subscription_throttles() {
21242118
transact_entity_operations(
21252119
&store,
21262120
TEST_SUBGRAPH_ID.clone(),
2127-
*TEST_BLOCK_4_PTR,
2121+
*TEST_BLOCK_3_PTR,
21282122
vec![user4],
21292123
)
21302124
.unwrap();
@@ -2232,7 +2226,7 @@ fn handle_large_string_with_index() {
22322226
store
22332227
.transact_block_operations(
22342228
TEST_SUBGRAPH_ID.clone(),
2235-
*TEST_BLOCK_4_PTR,
2229+
*TEST_BLOCK_3_PTR,
22362230
vec![
22372231
make_insert_op(ONE, &long_text),
22382232
make_insert_op(TWO, &other_text),

0 commit comments

Comments
 (0)