Skip to content

Commit

Permalink
debug additions to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zbuc committed Aug 16, 2024
1 parent 7cf7195 commit bd2d9f3
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions crates/core/app/tests/common/ibc_tests/relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use {
},
penumbra_proto::{util::tendermint_proxy::v1::GetBlockByHeightRequest, DomainType},
penumbra_transaction::{TransactionParameters, TransactionPlan},
sha2::Digest,
std::time::Duration,
};
#[allow(unused)]
Expand Down Expand Up @@ -394,6 +395,40 @@ impl MockRelayer {
MerkleProof::decode(client_state_of_b_on_a_response.clone().proof.as_slice())?;
let proof_conn_end_on_a =
MerkleProof::decode(connection_of_b_on_a_response.clone().proof.as_slice())?;

let existence_proofs: Vec<(Vec<u8>, Vec<u8>)> = proof_conn_end_on_a
.proofs
.iter()
.map(|proof| {
let p = proof.proof.clone().unwrap();
match p {
ics23::commitment_proof::Proof::Exist(p) => (p.key, p.value),
_ => (vec![], vec![]),
}
})
.inspect(|(k, v)| {
println!(
"proof_conn_end_on_a: k {} v {}",
hex::encode(k),
hex::encode(v)
);
})
.collect();

{
// TODO: change this into a different test after the bug is understood
assert_eq!(
hex::encode(&existence_proofs[0].0),
"636f6e6e656374696f6e732f636f6e6e656374696f6e2d30"
);
assert_eq!(hex::encode(&existence_proofs[0].1), "0a0f30372d74656e6465726d696e742d3012230a0131120d4f524445525f4f524445524544120f4f524445525f554e4f5244455245441801221d0a0f30372d74656e6465726d696e742d301a0a0a086962632d64617461288094ebdc03");
assert_eq!(hex::encode(&existence_proofs[1].0), "6962632d64617461");
assert_eq!(
hex::encode(&existence_proofs[1].1),
"e421a1ef4acacb331f598197adb7d3250f2b4f84a3e30721190fd00bfe914de3"
);
}

// TODO: too side-effecty?
chain_b_ibc.counterparty.connection_id = Some(chain_a_ibc.connection_id.clone());
chain_a_ibc.counterparty.connection_id = Some(chain_b_ibc.connection_id.clone());
Expand Down Expand Up @@ -455,6 +490,22 @@ impl MockRelayer {

// Execute the transaction, applying it to the chain state.
let pre_tx_snapshot = chain_b_ibc.storage.latest_snapshot();

// validate the chain b pre-tx storage root hash is what we expect:
let pre_tx_hash = pre_tx_snapshot.root_hash().await?;
assert_eq!(
hex::encode(pre_tx_hash),
"27572242ba7935d5c9acf4ee162fc1418be1f749677aecd0eb11d832bb8d8613".to_string()
);

// Validate the tx hash is what we expect:
let tx_hash = sha2::Sha256::digest(&tx.encode_to_vec());
assert_eq!(
hex::encode(tx_hash),
"8b741a3cfb2bcd4cf665780d3f9e18a6b954f15912591c1acc6d21de015848dc".to_string()
);

// execute the transaction containing the opentry message
chain_b_ibc
.node
.block()
Expand Down

0 comments on commit bd2d9f3

Please sign in to comment.