Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zone117x committed Oct 22, 2024
1 parent 6627606 commit 212a8e4
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 19 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions components/chainhook-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ prometheus = "0.13.3"
chainhook-types = { path = "../chainhook-types-rs" }

[dev-dependencies]
assert-json-diff = "2.0.2"
test-case = "3.1.0"

[features]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
"pox_cycle_index": 415,
"pox_cycle_length": 1050,
"pox_cycle_position": 1033,
"stacks_block_hash": "0x"
"stacks_block_hash": "0x",
"block_time": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -96,7 +101,12 @@
"pox_cycle_index": 415,
"pox_cycle_length": 1050,
"pox_cycle_position": 1033,
"stacks_block_hash": "0x"
"stacks_block_hash": "0x",
"block_time": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -177,7 +187,12 @@
"pox_cycle_index": 415,
"pox_cycle_length": 1050,
"pox_cycle_position": 1033,
"stacks_block_hash": "0x"
"stacks_block_hash": "0x",
"block_time": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -259,7 +274,12 @@
"pox_cycle_index": 415,
"pox_cycle_length": 1050,
"pox_cycle_position": 1033,
"stacks_block_hash": "0x"
"stacks_block_hash": "0x",
"block_time": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -340,7 +360,12 @@
"pox_cycle_index": 415,
"pox_cycle_length": 1050,
"pox_cycle_position": 1033,
"stacks_block_hash": "0x"
"stacks_block_hash": "0x",
"block_time": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -423,7 +448,12 @@
"pox_cycle_index": 415,
"pox_cycle_length": 1050,
"pox_cycle_position": 1033,
"stacks_block_hash": "0x"
"stacks_block_hash": "0x",
"block_time": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -505,7 +535,12 @@
"pox_cycle_index": 415,
"pox_cycle_length": 1050,
"pox_cycle_position": 1033,
"stacks_block_hash": "0x"
"stacks_block_hash": "0x",
"block_time": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -587,7 +622,12 @@
"pox_cycle_index": 415,
"pox_cycle_length": 1050,
"pox_cycle_position": 1033,
"stacks_block_hash": "0x"
"stacks_block_hash": "0x",
"block_time": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -670,7 +710,12 @@
"pox_cycle_index": 415,
"pox_cycle_length": 1050,
"pox_cycle_position": 1033,
"stacks_block_hash": "0x"
"stacks_block_hash": "0x",
"block_time": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -752,7 +797,12 @@
"pox_cycle_index": 415,
"pox_cycle_length": 1050,
"pox_cycle_position": 1033,
"stacks_block_hash": "0x"
"stacks_block_hash": "0x",
"block_time": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -834,7 +884,12 @@
"pox_cycle_index": 415,
"pox_cycle_length": 1050,
"pox_cycle_position": 1033,
"stacks_block_hash": "0x"
"stacks_block_hash": "0x",
"block_time": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -916,7 +971,12 @@
"pox_cycle_index": 415,
"pox_cycle_length": 1050,
"pox_cycle_position": 1033,
"stacks_block_hash": "0x"
"stacks_block_hash": "0x",
"block_time": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -998,7 +1058,12 @@
"pox_cycle_index": 415,
"pox_cycle_length": 1050,
"pox_cycle_position": 1033,
"stacks_block_hash": "0x"
"stacks_block_hash": "0x",
"block_time": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down Expand Up @@ -1090,7 +1155,12 @@
"pox_cycle_index": 415,
"pox_cycle_length": 1050,
"pox_cycle_position": 1033,
"stacks_block_hash": "0x"
"stacks_block_hash": "0x",
"block_time": null,
"cycle_number": null,
"reward_set": null,
"signer_bitvec": null,
"signer_signature": null
},
"parent_block_identifier": {
"hash": "0x",
Expand Down
9 changes: 4 additions & 5 deletions components/chainhook-sdk/src/chainhooks/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use crate::{
},
utils::AbstractStacksBlock,
};
use assert_json_diff::assert_json_eq;
use chainhook_types::{
StacksBlockUpdate, StacksChainEvent, StacksChainUpdatedWithBlocksData, StacksNetwork,
StacksTransactionData, StacksTransactionEvent, StacksTransactionEventPayload,
Expand Down Expand Up @@ -821,11 +822,9 @@ fn test_stacks_hook_action_file_append() {
handle_stacks_hook_action(trigger, &proofs, &EventObserverConfig::default(), &ctx).unwrap();
if let StacksChainhookOccurrence::File(path, bytes) = occurrence {
assert_eq!(path, "./".to_string());
let json: JsonValue = serde_json::from_slice(&bytes).unwrap();
let obj = json.as_object().unwrap();
let actual = serde_json::to_string_pretty(obj).unwrap();
let expected = get_expected_occurrence();
assert_eq!(expected, actual);
let actual: JsonValue = serde_json::from_slice(&bytes).unwrap();
let expected: JsonValue = serde_json::from_str(&get_expected_occurrence()).unwrap();
assert_json_eq!(expected, actual);
} else {
panic!("wrong occurrence type");
}
Expand Down

0 comments on commit 212a8e4

Please sign in to comment.