Skip to content

Commit

Permalink
add tests for enum types against Trezor proto enums
Browse files Browse the repository at this point in the history
  • Loading branch information
OBorce committed Dec 13, 2024
1 parent b1a5be4 commit c9cebcc
Show file tree
Hide file tree
Showing 4 changed files with 312 additions and 47 deletions.
151 changes: 127 additions & 24 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 trezor-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ strum = { version = "0.26", default-features = false, features = ["derive"] }
test-utils = { path = "../test-utils" }
common = { path = "../common" }
crypto = { path = "../crypto/" }
trezor-client = { git = "https://github.com/mintlayer/mintlayer-trezor-firmware", branch = "feature/mintlayer-pk", features = ["bitcoin", "mintlayer"] }

rstest.workspace = true
8 changes: 4 additions & 4 deletions trezor-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub enum OutputValue {
}

#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode, EnumDiscriminants)]
#[strum_discriminants(name(OutputTimeLockIndex), derive(EnumIter, FromPrimitive))]
#[strum_discriminants(name(OutputTimeLockType), derive(EnumIter, FromPrimitive))]
pub enum OutputTimeLock {
#[codec(index = 0)]
UntilHeight(#[codec(compact)] u64),
Expand Down Expand Up @@ -154,7 +154,7 @@ pub enum IsTokenFreezable {
}

#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode, EnumDiscriminants)]
#[strum_discriminants(name(TokenTotalSupplyIndex), derive(EnumIter, FromPrimitive))]
#[strum_discriminants(name(TokenTotalSupplyType), derive(EnumIter, FromPrimitive))]
pub enum TokenTotalSupply {
#[codec(index = 0)]
Fixed(Amount), // fixed to a certain amount
Expand Down Expand Up @@ -267,7 +267,7 @@ pub struct H256(pub [u8; 32]);
pub struct HtlcSecretHash(pub [u8; 20]);

#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode, Ord, PartialOrd, EnumDiscriminants)]
#[strum_discriminants(name(OutPointSourceIdIndex), derive(EnumIter, FromPrimitive))]
#[strum_discriminants(name(OutPointSourceIdType), derive(EnumIter, FromPrimitive))]
pub enum OutPointSourceId {
#[codec(index = 0)]
Transaction(H256),
Expand Down Expand Up @@ -323,7 +323,7 @@ type OrderId = H256;
type TokenId = H256;

#[derive(Encode, EnumDiscriminants)]
#[strum_discriminants(name(AccountCommandIndex), derive(EnumIter, FromPrimitive))]
#[strum_discriminants(name(AccountCommandType), derive(EnumIter, FromPrimitive))]
pub enum AccountCommand {
// Create certain amount of tokens and add them to circulating supply
#[codec(index = 0)]
Expand Down
Loading

0 comments on commit c9cebcc

Please sign in to comment.