Skip to content

Commit

Permalink
Introduces non-null starting balance for faucet transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco committed Dec 28, 2022
1 parent db0cac3 commit da794b8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
1 change: 1 addition & 0 deletions apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dev = ["namada/dev"]
std = ["ed25519-consensus/std", "rand/std", "rand_core/std"]
# for integration tests and test utilies
testing = ["dev"]
mainnet = []

abcipp = [
"namada/abcipp",
Expand Down
4 changes: 2 additions & 2 deletions apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ where
);
// Storage read must not fail, but there might
// be no value, in which
// case default (0) is returned
// case default (100) is returned
balance
.expect(
"Storage read in the protocol must \
not fail",
)
.unwrap_or_default()
.unwrap_or(Amount::from(100))
}
};

Expand Down
22 changes: 14 additions & 8 deletions apps/src/lib/node/ledger/shell/process_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ mod test_process_proposal {
}

/// Test that if the account submitting the tx is not known and the fee is
/// non-zero, [`process_proposal`] rejects that tx
/// non-zero, [`process_proposal`] rejects that tx. If test is run without [`mainnet`]
/// flag the tx should instead be accepted.
#[test]
fn test_wrapper_unknown_address() {
let (mut shell, _) = TestShell::new();
Expand All @@ -354,7 +355,7 @@ mod test_process_proposal {
);
let wrapper = WrapperTx::new(
Fee {
amount: 1.into(),
amount: 100.into(),
token: shell.storage.native_token.clone(),
},
&keypair,
Expand All @@ -377,12 +378,17 @@ mod test_process_proposal {
} else {
panic!("Test failed")
};
assert_eq!(response.result.code, u32::from(ErrorCodes::InvalidTx));
assert_eq!(
response.result.info,
"The address given does not have sufficient balance to pay fee"
.to_string(),
);
#[cfg(feature = "mainnet")]
{
assert_eq!(response.result.code, u32::from(ErrorCodes::InvalidTx));
assert_eq!(
response.result.info,
"The address given does not have sufficient balance to pay fee"
.to_string(),
);
}
#[cfg(not(feature = "mainnet"))]
assert_eq!(response.result.code, u32::from(ErrorCodes::Ok));
}

/// Test that if the account submitting the tx does
Expand Down
7 changes: 6 additions & 1 deletion apps/src/lib/node/ledger/shell/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ where
// case default (0) is returned
balance
.expect("Storage read in the protocol must not fail")
.unwrap_or_default()
.unwrap_or_else(|| {
#[cfg(not(feature = "mainnet"))]
return token::Amount::from(100);
#[cfg(feature = "mainnet")]
return token::Amount::default();
})
}

/// Lookup data about a validator from their protocol signing key
Expand Down

0 comments on commit da794b8

Please sign in to comment.