-
Notifications
You must be signed in to change notification settings - Fork 0
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
a7ad921
commit 81ff9f4
Showing
18 changed files
with
204 additions
and
45 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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,22 @@ | ||
use aiken/transaction/credential.{Address} | ||
use exunits_research/mock_data/placeholder.{ | ||
mock_pub_key_address, mock_script_address, mock_stake_cred, | ||
} | ||
|
||
test xu_full_address_pub_key() { | ||
let function = | ||
fn(_address: Address) { True } | ||
let stake_cred = | ||
mock_stake_cred(#"52e322a5dd87fe977c5ee5b91e3f42eedeccd6795a7ef4f158bd8892") | ||
let address = mock_pub_key_address(Some(stake_cred)) | ||
function(address) | ||
} | ||
|
||
test xu_full_address_script() { | ||
let function = | ||
fn(_address: Address) { True } | ||
let stake_cred = | ||
mock_stake_cred(#"52e322a5dd87fe977c5ee5b91e3f42eedeccd6795a7ef4f158bd8892") | ||
let address = mock_script_address(Some(stake_cred)) | ||
function(address) | ||
} |
38 changes: 38 additions & 0 deletions
38
lib/exunits-research/plutus-types/address/payment-address.ak
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,38 @@ | ||
use aiken/transaction/credential.{Address} | ||
use exunits_research/mock_data/placeholder.{ | ||
mock_pub_key_address, mock_pub_key_address_2, mock_script_address, | ||
} | ||
|
||
test xu_payment_address_pub_key() { | ||
let function = | ||
fn(_address: Address) { True } | ||
let address = mock_pub_key_address(None) | ||
function(address) | ||
} | ||
|
||
test xu_payment_address_script() { | ||
let function = | ||
fn(_address: Address) { True } | ||
let address = mock_script_address(None) | ||
function(address) | ||
} | ||
|
||
test xu_payment_address_pub_key_equal() { | ||
let address1 = mock_pub_key_address(None) | ||
let address2 = mock_pub_key_address(None) | ||
address1 == address2 | ||
} | ||
|
||
test xu_payment_address_pub_key_unequal() { | ||
let address1 = mock_pub_key_address(None) | ||
let address2 = mock_pub_key_address_2(None) | ||
address1 != address2 | ||
} | ||
|
||
test xu_payment_address_pass_in_pub_key_equal() { | ||
let compare = | ||
fn(address1: Address, address2: Address) { address1 == address2 } | ||
let address = mock_pub_key_address(None) | ||
let address2 = mock_pub_key_address(None) | ||
compare(address, address2) | ||
} |
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,25 @@ | ||
use aiken/transaction/credential.{Address, ScriptCredential} | ||
use exunits_research/mock_data/placeholder.{mock_script_address, | ||
mock_script_hex} | ||
|
||
test xu_script_hash() { | ||
let get_script_hash = | ||
fn(address: Address) { | ||
let Address { payment_credential, .. } = address | ||
expect ScriptCredential(_pub_key_hash) = payment_credential | ||
True | ||
} | ||
let address = mock_script_address(None) | ||
get_script_hash(address) | ||
} | ||
|
||
test xu_script_hash_get_and_check() { | ||
let get_script_hash = | ||
fn(address: Address) { | ||
let Address { payment_credential, .. } = address | ||
expect ScriptCredential(pub_key_hash) = payment_credential | ||
pub_key_hash == mock_script_hex() | ||
} | ||
let address = mock_script_address(None) | ||
get_script_hash(address) | ||
} |
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,40 +1,83 @@ | ||
test xu_bytearray_1() { | ||
let one_byte: ByteArray = #[0] | ||
one_byte == one_byte | ||
test xu_byte_1() { | ||
let deser = | ||
fn(_b) { True } | ||
deser(#[0]) | ||
} | ||
|
||
test xu_byte_array_32() { | ||
let bytestring: ByteArray = | ||
test xu_byte_24() { | ||
let deser = | ||
fn(_b) { True } | ||
deser(#"52e322a5dd87fe977c5ee5b91e3f42eedeccd6795a7ef4f158bd8892") | ||
} | ||
|
||
test xu_byte_1_equal() { | ||
let one_byte1: ByteArray = #[0] | ||
let one_byte2: ByteArray = #[0] | ||
one_byte1 == one_byte2 | ||
} | ||
|
||
test xu_byte_24_equal() { | ||
let bytestring1: ByteArray = | ||
#"52e322a5dd87fe977c5ee5b91e3f42eedeccd6795a7ef4f158bd8892" | ||
let bytestring2: ByteArray = | ||
#"52e322a5dd87fe977c5ee5b91e3f42eedeccd6795a7ef4f158bd8892" | ||
bytestring == bytestring | ||
bytestring1 == bytestring2 | ||
} | ||
|
||
test xu_byte1_incorrect() { | ||
let bytestring: ByteArray = #"52" | ||
let bytestring2: ByteArray = #"52" | ||
bytestring == bytestring2 | ||
test xu_byte_1_incorrect() { | ||
let bytestring1: ByteArray = #"00" | ||
let bytestring2: ByteArray = #"01" | ||
bytestring1 != bytestring2 | ||
} | ||
|
||
test xu_byte32_incorrect_at_head() { | ||
let bytestring: ByteArray = | ||
test xu_byte_24_incorrect_at_head() { | ||
let bytestring1: ByteArray = | ||
#"52e322a5dd87fe977c5ee5b91e3f42eedeccd6795a7ef4f158bd8892" | ||
let bytestring2: ByteArray = | ||
#"42e322a5dd87fe977c5ee5b91e3f42eedeccd6795a7ef4f158bd8892" | ||
bytestring != bytestring2 | ||
bytestring1 != bytestring2 | ||
} | ||
|
||
test xu_byte32_incorrect_at_tail() { | ||
let bytestring: ByteArray = | ||
test xu_byte_24_incorrect_at_tail() { | ||
let bytestring1: ByteArray = | ||
#"52e322a5dd87fe977c5ee5b91e3f42eedeccd6795a7ef4f158bd8892" | ||
let bytestring2: ByteArray = | ||
#"52e322a5dd87fe977c5ee5b91e3f42eedeccd6795a7ef4f158bd8893" | ||
bytestring != bytestring2 | ||
bytestring1 != bytestring2 | ||
} | ||
|
||
test xu_byte32_incorrect_at_middle() { | ||
let bytestring: ByteArray = | ||
test xu_byte_24_incorrect_at_middle() { | ||
let bytestring1: ByteArray = | ||
#"52e322a5dd87fe977c5ee5b91e4f42eedeccd6795a7ef4f158bd8893" | ||
let bytestring2: ByteArray = | ||
#"52e322a5dd87fe977c5ee5b91e3f42eedeccd6795a7ef4f158bd8893" | ||
bytestring != bytestring2 | ||
bytestring1 != bytestring2 | ||
} | ||
|
||
test xu_byte_3_bytes_diff_in_length_incorrect_long() { | ||
let bytestring1: ByteArray = | ||
#"52e322a5dd87fe977c5ee5b91e3f42eedeccd6795a7ef4f158bd8892" | ||
let bytestring3: ByteArray = | ||
#"52e322a5dd87fe977c5ee5b91e3f42eedeccd6795a7ef4f158" | ||
bytestring1 != bytestring3 | ||
} | ||
|
||
test xu_byte_4_bytes_diff_in_length_incorrect_long() { | ||
let bytestring1: ByteArray = | ||
#"52e322a5dd87fe977c5ee5b91e3f42eedeccd6795a7ef4f158bd8892" | ||
let bytestring3: ByteArray = | ||
#"52e322a5dd87fe977c5ee5b91e3f42eedeccd6795a7ef4f1" | ||
bytestring1 != bytestring3 | ||
} | ||
|
||
test xu_byte_7_bytes_diff_in_length_incorrect_short() { | ||
let bytestring1: ByteArray = #"52e322a5dd87fe97" | ||
let bytestring2: ByteArray = #"52" | ||
bytestring1 != bytestring2 | ||
} | ||
|
||
test xu_byte_8_bytes_diff_in_length_incorrect_short() { | ||
let bytestring1: ByteArray = #"52e322a5dd87fe97aa" | ||
let bytestring2: ByteArray = #"52" | ||
bytestring1 != bytestring2 | ||
} |
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
Empty file.
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,39 @@ | ||
# Primitives Test Report | ||
|
||
## ByteArray | ||
|
||
### Run the test result | ||
|
||
```sh | ||
aiken check -m xu_byte | ||
``` | ||
|
||
### Findings | ||
|
||
1. Passing `ByteArray` in a function does not cost any mem and step | ||
|
||
- Same as True or False comparison: [mem: 200, cpu: 23100] | ||
- Tests | ||
- [x] `xu_byte_1` | ||
- [x] `xu_byte_24` | ||
|
||
2. All `ByteArray` correct checking has [mem: 601], and Steps slightly different with length, where | ||
|
||
- 1 Byte: [cpu: 331935] | ||
- 32 Byte: [cpu: 332121] | ||
- Tests | ||
- [x] `xu_byte_1_equal` | ||
- [x] `xu_byte_24_equal` | ||
|
||
3. Incorrect `ByteArray checking` would take somewhat similar ExUnits regardless of length. Just up to some 4 bytes difference in length would cause a jump in around ~30000 steps. | ||
|
||
- Range of ExUnits: [mem: 1302, cpu: 573491 - 601656] | ||
- Tests | ||
- [x] xu_byte_1_incorrect | ||
- [x] xu_byte_24_incorrect_at_head | ||
- [x] xu_byte_24_incorrect_at_tail | ||
- [x] xu_byte_24_incorrect_at_middle | ||
- [x] xu_byte_3_bytes_diff_in_length_incorrect_long | ||
- [x] xu_byte_4_bytes_diff_in_length_incorrect_long | ||
- [x] xu_byte_7_bytes_diff_in_length_incorrect_short | ||
- [x] xu_byte_8_bytes_diff_in_length_incorrect_short |
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,5 @@ | ||
# All Tests | ||
|
||
## Simple True or False assertion | ||
|
||
- [mem: 200, cpu: 23100] |