Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
test: Test coverage for WebAssembly target on CI #72
Browse files Browse the repository at this point in the history
  • Loading branch information
polarbeargo committed Dec 6, 2021
1 parent f9ac018 commit 9a24361
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion base/src/numbers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ use wire_type::WireType;
#[wire_type(recurse = 2)]
pub struct Length(pub u32);

impl From<u32> for Length {
fn from(v: u32) -> Self {
Self(v)
}
}

#[derive(
Clone, Serialize, Deserialize, PartialEq, PartialOrd, Debug, Hash, Copy, Default, WireType,
)]
Expand Down Expand Up @@ -68,7 +74,7 @@ pub struct ExtendedU64_2(pub u64);
/// let amount = Amount(1000000030);
/// assert_eq!(amount.to_formatted_string(), "1.000000030");
/// ```
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, Hash, Default, WireType)]
#[derive(Copy, Clone, Serialize, Deserialize, PartialEq, Debug, Hash, Default, WireType)]
#[serde(from = "<Self as WireType>::WireType")]
#[serde(into = "<Self as WireType>::WireType")]
#[wire_type(recurse = 2)]
Expand Down
4 changes: 4 additions & 0 deletions consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ mina-rs-base = {version = "0.1.0", path = "../base"}

hex = "0.4"
thiserror = "1"

[dev-dependencies]
base64 = "0.13"
wasm-bindgen-test = "0.3"
quickcheck = "1"
proptest = "1.0.0"
8 changes: 7 additions & 1 deletion consensus/src/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ mod tests {
extern crate quickcheck;
use proptest::prelude::*;
use quickcheck::QuickCheck;
use wasm_bindgen_test::*;

#[test]
fn test_init_checkpoints() {
Expand Down Expand Up @@ -162,6 +163,8 @@ mod tests {

#[test]
fn equal_state_in_short_fork_range() {
// TODO: Generate blockchain position and epoch lengths.
// staking_epoch == root_epoch, next_staking_epoch == root_epoch + 1
let mut genesis: ProtocolState = Default::default();
init_checkpoints(&mut genesis).unwrap();

Expand All @@ -177,7 +180,7 @@ mod tests {
b.body.consensus_state.blockchain_length = Length(1);
b.body.consensus_state.epoch_count = Length(15);
b.body.consensus_state.curr_global_slot = GlobalSlot {
slot_number: GlobalSlotNumber(1),
slot_number: GlobalSlotNumber(0),
slots_per_epoch: Length(7140),
};

Expand All @@ -195,6 +198,7 @@ mod tests {
}

#[test]
#[wasm_bindgen_test]
fn gen_spot_pair_short_aligned_generates_pairs_of_states_in_short_fork_range() {
// TODO: Both states will share their staking epoch checkpoints.
let mut genesis: ProtocolState = Default::default();
Expand Down Expand Up @@ -229,6 +233,7 @@ mod tests {
}

#[test]
#[wasm_bindgen_test]
fn gen_spot_pair_short_misaligned_generates_pairs_of_states_in_short_fork_range() {
// TODO: Compute the root epoch position of `b`. This needs to be one epoch ahead of a, so we
// compute it by extending the root epoch position of `a` by a single epoch
Expand Down Expand Up @@ -266,6 +271,7 @@ mod tests {
}

#[test]
#[wasm_bindgen_test]
fn gen_spot_pair_long_generates_pairs_of_states_in_long_fork_range() {
let mut genesis: ProtocolState = Default::default();
init_checkpoints(&mut genesis).unwrap();
Expand Down

0 comments on commit 9a24361

Please sign in to comment.