-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
833836e
commit 1fffcf4
Showing
3 changed files
with
14 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,5 @@ | ||
use aiken/bytearray | ||
use aiken/dict.{Dict} | ||
use aiken/list | ||
use ibc/core/ics_004/types/packet.{Packet} | ||
|
||
pub type MockModuleDatum { | ||
opened_channels: Dict<ByteArray, Bool>, | ||
received_packets: List<ByteArray>, | ||
} | ||
|
||
pub fn validate_on_chan_open_init( | ||
old_datum: MockModuleDatum, | ||
updated_datum: MockModuleDatum, | ||
channel_id: ByteArray, | ||
) -> Bool { | ||
expect !dict.has_key(old_datum.opened_channels, channel_id) | ||
|
||
let expected_datum = | ||
MockModuleDatum { | ||
..old_datum, | ||
opened_channels: dict.insert( | ||
old_datum.opened_channels, | ||
channel_id, | ||
True, | ||
bytearray.compare, | ||
), | ||
} | ||
|
||
expect expected_datum == updated_datum | ||
|
||
True | ||
} | ||
|
||
pub fn validate_on_chan_open_try( | ||
old_datum: MockModuleDatum, | ||
updated_datum: MockModuleDatum, | ||
channel_id: ByteArray, | ||
) -> Bool { | ||
expect !dict.has_key(old_datum.opened_channels, channel_id) | ||
|
||
let expected_datum = | ||
MockModuleDatum { | ||
..old_datum, | ||
opened_channels: dict.insert( | ||
old_datum.opened_channels, | ||
channel_id, | ||
True, | ||
bytearray.compare, | ||
), | ||
} | ||
|
||
expect expected_datum == updated_datum | ||
|
||
True | ||
} | ||
|
||
pub fn validate_on_chan_open_ack( | ||
old_datum: MockModuleDatum, | ||
updated_datum: MockModuleDatum, | ||
channel_id: ByteArray, | ||
) -> Bool { | ||
expect Some(True) = dict.get(old_datum.opened_channels, channel_id) | ||
|
||
expect old_datum == updated_datum | ||
|
||
True | ||
} | ||
|
||
pub fn validate_on_chan_open_confirm( | ||
old_datum: MockModuleDatum, | ||
updated_datum: MockModuleDatum, | ||
channel_id: ByteArray, | ||
) -> Bool { | ||
expect Some(True) = dict.get(old_datum.opened_channels, channel_id) | ||
|
||
expect old_datum == updated_datum | ||
|
||
True | ||
} | ||
|
||
pub fn validate_on_recv_packet( | ||
old_datum: MockModuleDatum, | ||
updated_datum: MockModuleDatum, | ||
channel_id: ByteArray, | ||
packet: Packet, | ||
) -> Bool { | ||
expect Some(True) = dict.get(old_datum.opened_channels, channel_id) | ||
|
||
let expected_datum = | ||
MockModuleDatum { | ||
..old_datum, | ||
received_packets: list.push(old_datum.received_packets, packet.data), | ||
} | ||
|
||
expect expected_datum == updated_datum | ||
|
||
True | ||
received_packets: List<Packet>, | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use aiken/transaction.{ScriptContext} | ||
use ibc/apps/mock/datum.{MockModuleDatum} | ||
use ibc/core/ics_005/types/ibc_module_redeemer.{IBCModuleRedeemer} | ||
|
||
validator { | ||
fn spend_mock_module( | ||
_datum: MockModuleDatum, | ||
_redeemer: IBCModuleRedeemer, | ||
_context: ScriptContext, | ||
) -> Bool { | ||
True | ||
} | ||
} |