Skip to content

Commit

Permalink
ntt-accountant: initial integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-gray committed Feb 25, 2024
1 parent a06b581 commit 4ac1a15
Show file tree
Hide file tree
Showing 5 changed files with 648 additions and 2 deletions.
6 changes: 6 additions & 0 deletions cosmwasm/contracts/ntt-global-accountant/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ fn handle_observation(
.context("failed to load destination peer")?
.ok_or_else(|| ContractError::MissingDestinationPeerRegistration(o.emitter_chain.into()))?;
if destination_peer != sender {
// SECURITY defense-in-depth:
// should never get here due to strict registration ordering restrictions
// the lookups above would have failed instead
bail!("peers are not cross-registered")
}

Expand Down Expand Up @@ -518,6 +521,9 @@ fn handle_ntt_vaa(
ContractError::MissingDestinationPeerRegistration(source_chain.into())
})?;
if destination_peer != sender {
// SECURITY defense-in-depth:
// should never get here due to strict registration ordering restrictions
// the lookups above would have failed instead
bail!("peers are not cross-registered")
}

Expand Down
4 changes: 2 additions & 2 deletions cosmwasm/contracts/ntt-global-accountant/src/structs/ntt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ mod test {

#[test]
pub fn lock_init() {
// c83e3d2e000000000000000000000000bb807f76cda53b1b4256e1b6f33bb46be36508e3000000000000000000000000002a68f967bfa230780a385175d0c86ae4048d3096120000000000000000000000000000000000000000000000000000
// c83e3d2e000000000000000000000000bb807f76cda53b1b4256e1b6f33bb46be36508e3000000000000000000000000002a68f967bfa230780a385175d0c86ae4048d309612
let payload = [
0xc8, 0x3e, 0x3d, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xbb, 0x80, 0x7f, 0x76, 0xcd, 0xa5, 0x3b, 0x1b, 0x42, 0x56, 0xe1, 0xb6,
Expand Down Expand Up @@ -150,7 +150,7 @@ mod test {

#[test]
pub fn burn_init() {
// c83e3d2e0000000000000000000000001fc14f21b27579f4f23578731cd361cca8aa39f701000000000000000000000000eb502b1d35e975321b21cce0e8890d20a7eb289d120000000000000000000000000000000000000000000000000000
// c83e3d2e0000000000000000000000001fc14f21b27579f4f23578731cd361cca8aa39f701000000000000000000000000eb502b1d35e975321b21cce0e8890d20a7eb289d12
let payload = [
0xc8, 0x3e, 0x3d, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1f, 0xc1, 0x4f, 0x21, 0xb2, 0x75, 0x79, 0xf4, 0xf2, 0x35, 0x78, 0x73,
Expand Down
Loading

0 comments on commit 4ac1a15

Please sign in to comment.