Skip to content

Commit ddf7d35

Browse files
committed
test/e2e: add a test with an account derived from secp256k1 key
1 parent 8edc06c commit ddf7d35

5 files changed

Lines changed: 61 additions & 6 deletions

File tree

apps/src/lib/config/genesis.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -995,9 +995,14 @@ pub fn genesis(num_validators: u64) -> Genesis {
995995
public_key: None,
996996
storage: HashMap::default(),
997997
};
998-
let implicit_accounts = vec![ImplicitAccount {
999-
public_key: wallet::defaults::daewon_keypair().ref_to(),
1000-
}];
998+
let implicit_accounts = vec![
999+
ImplicitAccount {
1000+
public_key: wallet::defaults::daewon_keypair().ref_to(),
1001+
},
1002+
ImplicitAccount {
1003+
public_key: wallet::defaults::ester_keypair().ref_to(),
1004+
},
1005+
];
10011006
let default_user_tokens = token::Amount::whole(1_000_000);
10021007
let default_key_tokens = token::Amount::whole(1_000);
10031008
let mut balances: HashMap<Address, token::Amount> = HashMap::from_iter([

apps/src/lib/wallet/defaults.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
#[cfg(any(test, feature = "dev"))]
44
pub use dev::{
55
addresses, albert_address, albert_keypair, bertha_address, bertha_keypair,
6-
christel_address, christel_keypair, daewon_address, daewon_keypair, keys,
7-
validator_address, validator_keypair, validator_keys,
6+
christel_address, christel_keypair, daewon_address, daewon_keypair,
7+
ester_address, ester_keypair, keys, validator_address, validator_keypair,
8+
validator_keys,
89
};
910
use namada::ledger::wallet::alias::Alias;
1011
use namada::ledger::{eth_bridge, governance, pos};
@@ -107,6 +108,7 @@ mod dev {
107108
("bertha".into(), bertha_keypair()),
108109
("christel".into(), christel_keypair()),
109110
("daewon".into(), daewon_keypair()),
111+
("ester".into(), ester_keypair()),
110112
("validator".into(), validator_keypair()),
111113
]
112114
}
@@ -137,6 +139,7 @@ mod dev {
137139
("bertha".into(), bertha_address()),
138140
("christel".into(), christel_address()),
139141
("daewon".into(), daewon_address()),
142+
("ester".into(), ester_address()),
140143
];
141144
let token_addresses = tokens()
142145
.into_iter()
@@ -166,6 +169,11 @@ mod dev {
166169
(&daewon_keypair().ref_to()).into()
167170
}
168171

172+
/// An implicit user address for testing & development
173+
pub fn ester_address() -> Address {
174+
(&ester_keypair().ref_to()).into()
175+
}
176+
169177
/// An established validator address for testing & development
170178
pub fn validator_address() -> Address {
171179
Address::decode("atest1v4ehgw36ggcnsdee8qerswph8y6ry3p5xgunvve3xaqngd3kxc6nqwz9gseyydzzg5unys3ht2n48q").expect("The token address decoding shouldn't fail")
@@ -219,6 +227,18 @@ mod dev {
219227
ed_sk.try_to_sk().unwrap()
220228
}
221229

230+
pub fn ester_keypair() -> common::SecretKey {
231+
// generated from
232+
// [`namada::types::key::secp256k1::gen_keypair`]
233+
let bytes = [
234+
54, 144, 147, 226, 3, 93, 132, 247, 42, 126, 90, 23, 200, 155, 122,
235+
147, 139, 93, 8, 204, 135, 178, 40, 152, 5, 227, 175, 204, 102,
236+
239, 154, 66,
237+
];
238+
let sk = secp256k1::SecretKey::try_from_slice(&bytes).unwrap();
239+
sk.try_to_sk().unwrap()
240+
}
241+
222242
pub fn validator_keypair() -> common::SecretKey {
223243
// generated from
224244
// [`namada::types::key::ed25519::gen_keypair`]

genesis/e2e-tests-single-node.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Bertha = 1000000
3636
Christel = 1000000
3737
"Christel.public_key" = 100
3838
Daewon = 1000000
39+
Ester = 1000000
3940
faucet = 9223372036
4041
"faucet.public_key" = 100
4142
"validator-0.public_key" = 100
@@ -48,6 +49,7 @@ Albert = 1000000
4849
Bertha = 1000000
4950
Christel = 1000000
5051
Daewon = 1000000
52+
Ester = 1000000
5153
faucet = 9223372036854
5254

5355
[token.ETH]
@@ -58,6 +60,7 @@ Albert = 1000000
5860
Bertha = 1000000
5961
Christel = 1000000
6062
Daewon = 1000000
63+
Ester = 1000000
6164
faucet = 9223372036854
6265

6366
[token.DOT]
@@ -68,6 +71,7 @@ Albert = 1000000
6871
Bertha = 1000000
6972
Christel = 1000000
7073
Daewon = 1000000
74+
Ester = 1000000
7175
faucet = 9223372036854
7276

7377
[token.Schnitzel]
@@ -78,6 +82,7 @@ Albert = 1000000
7882
Bertha = 1000000
7983
Christel = 1000000
8084
Daewon = 1000000
85+
Ester = 1000000
8186
faucet = 9223372036854
8287

8388
[token.Apfel]
@@ -88,6 +93,7 @@ Albert = 1000000
8893
Bertha = 1000000
8994
Christel = 1000000
9095
Daewon = 1000000
96+
Ester = 1000000
9197
faucet = 9223372036854
9298

9399
[token.Kartoffel]
@@ -99,6 +105,7 @@ Albert = 1000000
99105
Bertha = 1000000
100106
Christel = 1000000
101107
Daewon = 1000000
108+
Ester = 1000000
102109
faucet = 9223372036854
103110

104111
# Some established accounts present at genesis.
@@ -120,6 +127,8 @@ vp = "vp_masp"
120127

121128
[implicit.Daewon]
122129

130+
[implicit.Ester]
131+
123132
# Wasm VP definitions
124133

125134
# Implicit VP

tests/src/e2e/ledger_tests.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ fn ledger_txs_and_queries() -> Result<()> {
405405
"--node",
406406
&validator_one_rpc,
407407
],
408-
// Submit a token transfer tx (from an implicit account)
408+
// Submit a token transfer tx (from an ed25519 implicit account)
409409
vec![
410410
"transfer",
411411
"--source",
@@ -425,6 +425,26 @@ fn ledger_txs_and_queries() -> Result<()> {
425425
"--node",
426426
&validator_one_rpc,
427427
],
428+
// Submit a token transfer tx (from a secp256k1 implicit account)
429+
vec![
430+
"transfer",
431+
"--source",
432+
ESTER,
433+
"--target",
434+
ALBERT,
435+
"--token",
436+
NAM,
437+
"--amount",
438+
"10.1",
439+
"--gas-amount",
440+
"0",
441+
"--gas-limit",
442+
"0",
443+
"--gas-token",
444+
NAM,
445+
"--node",
446+
&validator_one_rpc,
447+
],
428448
// 3. Submit a transaction to update an account's validity
429449
// predicate
430450
vec![

tests/src/e2e/setup.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,7 @@ pub mod constants {
795795
pub const CHRISTEL: &str = "Christel";
796796
pub const CHRISTEL_KEY: &str = "Christel-key";
797797
pub const DAEWON: &str = "Daewon";
798+
pub const ESTER: &str = "Ester";
798799
pub const MATCHMAKER_KEY: &str = "matchmaker-key";
799800
pub const MASP: &str = "atest1v4ehgw36xaryysfsx5unvve4g5my2vjz89p52sjxxgenzd348yuyyv3hg3pnjs35g5unvde4ca36y5";
800801

0 commit comments

Comments
 (0)