Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unit/e2e test #1062

Merged
merged 2 commits into from
Jan 23, 2023
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
2 changes: 2 additions & 0 deletions .changelog/unreleased/testing/1062-fix-e2e-test-failures.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Address failing e2e tests which were not caught earlier.
([#1062](https://github.com/anoma/namada/pull/1062))
3 changes: 2 additions & 1 deletion apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ where
Amount::from(0).try_to_vec().unwrap(),
)
.unwrap();
tx_event["log"] =
tx_event["info"] =
"Insufficient balance for fee".into();
tx_event["code"] = ErrorCodes::InvalidTx.into();
tx_event["gas_used"] = "0".to_string();

response.events.push(tx_event);
continue;
Expand Down
22 changes: 18 additions & 4 deletions core/src/ledger/parameters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl Parameters {
&vp_whitelist
.iter()
.map(|id| id.to_lowercase())
.collect::<String>(),
.collect::<Vec<String>>(),
);
storage.write(&vp_whitelist_key, vp_whitelist_value).expect(
"Vp whitelist parameter must be initialized in the genesis block",
Expand All @@ -161,7 +161,7 @@ impl Parameters {
&tx_whitelist
.iter()
.map(|id| id.to_lowercase())
.collect::<String>(),
.collect::<Vec<String>>(),
);
storage.write(&tx_whitelist_key, tx_whitelist_value).expect(
"Tx whitelist parameter must be initialized in the genesis block",
Expand Down Expand Up @@ -273,7 +273,14 @@ where
H: ledger_storage::StorageHasher,
{
let key = storage::get_vp_whitelist_storage_key();
update(storage, &value, key)
update(
storage,
&value
.iter()
.map(|id| id.to_lowercase())
.collect::<Vec<String>>(),
key,
)
}

/// Update the tx whitelist parameter in storage. Returns the parameters and gas
Expand All @@ -287,7 +294,14 @@ where
H: ledger_storage::StorageHasher,
{
let key = storage::get_tx_whitelist_storage_key();
update(storage, &value, key)
update(
storage,
&value
.iter()
.map(|id| id.to_lowercase())
.collect::<Vec<String>>(),
key,
)
}

/// Update the epoch parameter in storage. Returns the parameters and gas
Expand Down
2 changes: 1 addition & 1 deletion genesis/e2e-tests-single-node.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ vp = "vp_token"
Albert = 1000000
"Albert.public_key" = 100
Bertha = 1000000
"Bertha.public_key" = 100
"Bertha.public_key" = 2000
Christel = 1000000
"Christel.public_key" = 100
Daewon = 1000000
Expand Down
10 changes: 5 additions & 5 deletions tests/src/e2e/ledger_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fn test_node_connectivity_and_consensus() -> Result<()> {
// 4. Check that all the nodes processed the tx with the same result
let mut validator_0 = bg_validator_0.foreground();
let mut validator_1 = bg_validator_1.foreground();
let expected_result = "all VPs accepted transaction";
let expected_result = "successful txs: 1";
// We cannot check this on non-validator node as it might sync without
// applying the tx itself, but its state should be the same, checked below.
validator_0.exp_string(expected_result)?;
Expand Down Expand Up @@ -1704,7 +1704,7 @@ fn invalid_transactions() -> Result<()> {

client.assert_success();
let mut ledger = bg_ledger.foreground();
ledger.exp_string("some VPs rejected transaction")?;
ledger.exp_string("rejected txs: 1")?;

// Wait to commit a block
ledger.exp_regex(r"Committed block hash.*, height: [0-9]+")?;
Expand Down Expand Up @@ -2182,7 +2182,7 @@ fn ledger_many_txs_in_a_block() -> Result<()> {
"--token",
NAM,
"--amount",
"10.1",
"1.01",
"--gas-amount",
"0",
"--gas-limit",
Expand All @@ -2195,7 +2195,7 @@ fn ledger_many_txs_in_a_block() -> Result<()> {
// 2. Spawn threads each submitting token transfer tx
// We collect to run the threads in parallel.
#[allow(clippy::needless_collect)]
let tasks: Vec<std::thread::JoinHandle<_>> = (0..3)
let tasks: Vec<std::thread::JoinHandle<_>> = (0..4)
.into_iter()
.map(|_| {
let test = Arc::clone(&test);
Expand Down Expand Up @@ -3083,7 +3083,7 @@ fn test_genesis_validators() -> Result<()> {
let mut validator_0 = bg_validator_0.foreground();
let mut validator_1 = bg_validator_1.foreground();

let expected_result = "all VPs accepted transaction";
let expected_result = "successful txs: 1";
// We cannot check this on non-validator node as it might sync without
// applying the tx itself, but its state should be the same, checked below.
validator_0.exp_string(expected_result)?;
Expand Down
2 changes: 1 addition & 1 deletion tests/src/e2e/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub fn network(

genesis.parameters.vp_whitelist =
Some(get_all_wasms_hashes(&working_dir, Some("vp_")));
genesis.parameters.vp_whitelist =
genesis.parameters.tx_whitelist =
Some(get_all_wasms_hashes(&working_dir, Some("tx_")));

// Run the provided function on it
Expand Down
3 changes: 2 additions & 1 deletion wasm/wasm_source/src/vp_implicit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,8 @@ mod tests {
std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm");

// hardcoded hash of VP_ALWAYS_TRUE_WASM
tx_env.init_parameters(None, None, Some(vec!["E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855".to_string()]));
// this must be lower case, as its written into genesis as lower case
tx_env.init_parameters(None, None, Some(vec!["e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855".to_string()]));

// Spawn the accounts to be able to modify their storage
tx_env.spawn_accounts([&vp_owner]);
Expand Down
8 changes: 6 additions & 2 deletions wasm/wasm_source/src/vp_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,11 @@ mod tests {
std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm");

let vp_hash = sha256(&vp_code);
tx_env.init_parameters(None, Some(vec![vp_hash.to_string()]), None);
tx_env.init_parameters(
None,
Some(vec![vp_hash.to_string().to_lowercase()]),
None,
);

// Spawn the accounts to be able to modify their storage
tx_env.spawn_accounts([&vp_owner]);
Expand Down Expand Up @@ -728,7 +732,7 @@ mod tests {
std::fs::read(VP_ALWAYS_TRUE_WASM).expect("cannot load wasm");

// hardcoded hash of VP_ALWAYS_TRUE_WASM
tx_env.init_parameters(None, None, Some(vec!["E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855".to_string()]));
tx_env.init_parameters(None, None, Some(vec!["E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855".to_string().to_lowercase()]));

// Spawn the accounts to be able to modify their storage
tx_env.spawn_accounts([&vp_owner]);
Expand Down