Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest]
features:
- evm,std
- evm,std,scale
- substrate,std
- evm
test-features:
- evm,std
- evm,std,scale
- substrate,std
runs-on: ${{ matrix.os }}
# Name should be the OS name only (e.g. Linux, macOS, Windows)
Expand Down
37 changes: 37 additions & 0 deletions proposals/src/proposal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,41 @@ impl Proposal {
pub fn is_unsigned(&self) -> bool {
matches!(self, Proposal::Unsigned { .. })
}

/// Returns a boolean indicating if proposal is AnchorUpdate kind.
pub fn is_anchor_update_proposal(&self) -> bool {
match self.kind() {
ProposalKind::AnchorUpdate => true,
_ => false,
}
}
}

#[cfg(test)]
mod test {
use crate::{Proposal, ProposalKind};
use scale_codec::{Decode, Encode};

#[test]
pub fn test_decode_proposal_from_bytes() {
let anchor_update_proposa_bytes = hex_literal::hex!(
"000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa010000000004"
"cafebabe00000001000102030405060708090a0b0c0d"
"0e0f101112131415161718191a1b1c1d1e1f"
"000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa010000000001"
);
let proposal = Proposal::Unsigned {
kind: ProposalKind::AnchorUpdate,
data: anchor_update_proposa_bytes.to_vec(),
};

let proposal_bytes = proposal.encode();

let decoded_proposal =
Proposal::decode(&mut proposal_bytes.as_slice()).unwrap();
assert_eq!(decoded_proposal.kind(), proposal.kind());
assert_eq!(decoded_proposal.data(), proposal.data());
assert_eq!(decoded_proposal.is_unsigned(), true);
assert_eq!(decoded_proposal.is_anchor_update_proposal(), true);
}
}