Skip to content

Commit

Permalink
test: Fix valid_since test
Browse files Browse the repository at this point in the history
  • Loading branch information
keroro520 committed Jul 8, 2019
1 parent e7cd652 commit 7a5bc76
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/src/specs/tx_pool/valid_since.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ impl ValidSince {
DEFAULT_TX_PROPOSAL_WINDOW.0 + 2
}

// (current, current+cellbase_maturity): Err(InvalidTx(CellbaseImmaturity))
// [current+cellbase_maturity, current+relative_number): Err(InvalidTx(Immature))
pub fn test_since_relative_block_number(&self, node: &Node) {
node.generate_block();
let relative: BlockNumber = self.cellbase_maturity() + 5;
Expand All @@ -48,7 +50,7 @@ impl ValidSince {
};

// Failed to send transaction since CellbaseImmaturity
for _ in 0..self.cellbase_maturity() {
for _ in 1..self.cellbase_maturity() {
assert_send_transaction_fail(node, &transaction, "InvalidTx(CellbaseImmaturity)");
node.generate_block();
}
Expand All @@ -71,6 +73,8 @@ impl ValidSince {
);
}

// (current, current+cellbase_maturity): Err(InvalidTx(CellbaseImmaturity))
// [current+cellbase_maturity, absolute_number): Err(InvalidTx(Immature))
pub fn test_since_absolute_block_number(&self, node: &Node) {
node.generate_block();
let absolute: BlockNumber =
Expand All @@ -82,14 +86,14 @@ impl ValidSince {
};

// Failed to send transaction since CellbaseImmaturity
for _ in 0..self.cellbase_maturity() {
for _ in 1..self.cellbase_maturity() {
assert_send_transaction_fail(node, &transaction, "InvalidTx(CellbaseImmaturity)");
node.generate_block();
}

// Failed to send transaction since SinceImmaturity
let tip_number = node.rpc_client().get_tip_block_number();
for _ in tip_number..absolute {
for _ in tip_number + 1..absolute {
assert_send_transaction_fail(node, &transaction, "InvalidTx(Immature)");
node.generate_block();
}
Expand Down

0 comments on commit 7a5bc76

Please sign in to comment.