Skip to content

Commit

Permalink
Migrate to new address format in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sug0 committed Oct 26, 2023
1 parent 1c27ea2 commit 49d7b58
Show file tree
Hide file tree
Showing 22 changed files with 124 additions and 95 deletions.
16 changes: 10 additions & 6 deletions apps/src/lib/node/ledger/ethereum_oracle/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,11 @@ pub mod eth_events {
raw.transfers,
vec![ethereum_structs::ChainTransfer {
amount: 100u64.into(),
from: ethabi::Address::from_str("0x5FbDB2315678afecb367f032d93F642f64180aa3").unwrap(),
to: "atest1v4ehgw36xuunwd6989prwdfkxqmnvsfjxs6nvv6xxucrs3f3xcmns3fcxdzrvvz9xverzvzr56le8f".into(),
from: ethabi::Address::from_str(
"0x5FbDB2315678afecb367f032d93F642f64180aa3"
)
.unwrap(),
to: "tnam1q9uh06dh2crk5fzk8acgu9ncaq7kpceppsspuya2".into(),
}]
)
}
Expand Down Expand Up @@ -423,8 +426,10 @@ pub mod eth_events {
#[test]
fn test_decoding_roundtrips() {
let erc = EthAddress([1; 20]);
let address = Address::from_str("atest1v4ehgw36gep5ysecxq6nyv3jg3zygv3e89qn2vp48pryxsf4xpznvve5gvmy23fs89pryvf5a6ht90")
.expect("Test failed");
let address = Address::from_str(
"tnam1q87teqzjytwa9xd9qk8u558xxnrwuzdjzs7zvhzr",
)
.expect("Test failed");
let amount = Amount::from(42u64);
let confs = 50u32;
let uint = Uint::from(42u64);
Expand Down Expand Up @@ -468,8 +473,7 @@ pub mod eth_events {
#[test]
fn test_complex_round_trips() {
let address: String =
"atest1v4ehgw36gep5ysecxq6nyv3jg3zygv3e89qn2vp48pryxsf4xpznvve5gvmy23fs89pryvf5a6ht90"
.into();
"tnam1q87teqzjytwa9xd9qk8u558xxnrwuzdjzs7zvhzr".into();
let nam_transfers = TransferToChainFilter {
transfers: vec![
ethereum_structs::ChainTransfer {
Expand Down
14 changes: 9 additions & 5 deletions apps/src/lib/wallet/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,25 @@ mod dev {

/// An established user address for testing & development
pub fn albert_address() -> Address {
Address::decode("atest1v4ehgw368ycryv2z8qcnxv3cxgmrgvjpxs6yg333gym5vv2zxepnj334g4rryvj9xucrgve4x3xvr4").expect("The token address decoding shouldn't fail")
Address::decode("tnam1qxgzrwqn9qny9fzd7xnlrdkf7hhj9ecyx5mv3sgw")
.expect("The token address decoding shouldn't fail")
}

/// An established user address for testing & development
pub fn bertha_address() -> Address {
Address::decode("atest1v4ehgw36xvcyyvejgvenxs34g3zygv3jxqunjd6rxyeyys3sxy6rwvfkx4qnj33hg9qnvse4lsfctw").expect("The token address decoding shouldn't fail")
Address::decode("tnam1qyctxtpnkhwaygye0sftkq28zedf774xc5a2m7st")
.expect("The token address decoding shouldn't fail")
}

/// An established user address for testing & development
pub fn christel_address() -> Address {
Address::decode("atest1v4ehgw36x3qng3jzggu5yvpsxgcngv2xgguy2dpkgvu5x33kx3pr2w2zgep5xwfkxscrxs2pj8075p").expect("The token address decoding shouldn't fail")
Address::decode("tnam1q99ylwumqqs5r7uwgmyu7e94n07vjeqr4g970na0")
.expect("The token address decoding shouldn't fail")
}

/// An implicit user address for testing & development
pub fn daewon_address() -> Address {
// "atest1d9khqw36xprrzdpk89rrws69g4z5vd6pgv65gvjrgeqnv3pcg4zns335xymry335gcerqs3etd0xfa"
// "tnam1qq83g60hemh00tza9naxmrhg7stz7neqhytnj6l0"
(&daewon_keypair().ref_to()).into()
}

Expand All @@ -192,7 +195,8 @@ mod dev {

/// An established validator address for testing & development
pub fn validator_address() -> Address {
Address::decode("atest1v4ehgw36ggcnsdee8qerswph8y6ry3p5xgunvve3xaqngd3kxc6nqwz9gseyydzzg5unys3ht2n48q").expect("The token address decoding shouldn't fail")
Address::decode("tnam1qxcc0xpgs72z6s5kx9ayvejs3mftf05jkutgz2cc")
.expect("The token address decoding shouldn't fail")
}

pub fn albert_keypair() -> common::SecretKey {
Expand Down
10 changes: 6 additions & 4 deletions apps/src/lib/wallet/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ mod test_wallet {
let validator_keys =
gen_validator_keys(None, None, SchemeType::Ed25519);
store.add_validator_data(
Address::decode("atest1v4ehgw36x3prswzxggunzv6pxqmnvdj9xvcyzvpsggeyvs3cg9qnywf589qnwvfsg5erg3fkl09rg5").unwrap(),
validator_keys
Address::decode("tnam1q99c37u38grkdcc2qze0hz4zjjd8zr3yucd3mzgz")
.unwrap(),
validator_keys,
);
let data = store.encode();
let _ = Store::decode(data).expect("Test failed");
Expand All @@ -168,8 +169,9 @@ mod test_wallet {
let validator_keys =
gen_validator_keys(None, None, SchemeType::Secp256k1);
store.add_validator_data(
Address::decode("atest1v4ehgw36x3prswzxggunzv6pxqmnvdj9xvcyzvpsggeyvs3cg9qnywf589qnwvfsg5erg3fkl09rg5").unwrap(),
validator_keys
Address::decode("tnam1q99c37u38grkdcc2qze0hz4zjjd8zr3yucd3mzgz")
.unwrap(),
validator_keys,
);
let data = store.encode();
let _ = Store::decode(data).expect("Test failed");
Expand Down
4 changes: 2 additions & 2 deletions core/proptest-regressions/ledger/storage/wl_storage.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/src/ledger/eth_bridge/storage/bridge_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ mod test_bridge_pool_tree {

/// An established user address for testing & development
fn bertha_address() -> Address {
Address::decode("atest1v4ehgw36xvcyyvejgvenxs34g3zygv3jxqunjd6rxyeyys3sxy6rwvfkx4qnj33hg9qnvse4lsfctw")
Address::decode("tnam1qyctxtpnkhwaygye0sftkq28zedf774xc5a2m7st")
.expect("The token address decoding shouldn't fail")
}

Expand Down
4 changes: 3 additions & 1 deletion core/src/ledger/eth_bridge/storage/whitelist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ mod tests {
suffix: KeyType::Whitelisted,
}
.into();
let expected = "#atest1v9hx7w36g42ysgzzwf5kgem9ypqkgerjv4ehxgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpq8f99ew/whitelist/0x6b175474e89094c44da98b954eedeac495271d0f/whitelisted";
let expected = "#tnam1quqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqfgdmms/\
whitelist/0x6b175474e89094c44da98b954eedeac495271d0f/\
whitelisted";
assert_eq!(expected, key.to_string());
}

Expand Down
17 changes: 10 additions & 7 deletions core/src/ledger/eth_bridge/storage/wrapped_erc20s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ mod test {
const MULTITOKEN_ADDRESS: Address =
Address::Internal(InternalAddress::Multitoken);
const ARBITRARY_OWNER_ADDRESS: &str =
"atest1d9khqw36x9zyxwfhgfpygv2pgc65gse4gy6rjs34gfzr2v69gy6y23zpggurjv2yx5m52sesu6r4y4";
"tnam1qqwuj7aart6ackjfkk7486jwm2ufr4t7cq4535u4";

fn dai_erc20_token() -> Address {
Address::Internal(InternalAddress::Erc20(DAI_ERC20_ETH_ADDRESS))
Expand Down Expand Up @@ -162,9 +162,11 @@ mod test {
&Address::from_str(ARBITRARY_OWNER_ADDRESS).unwrap(),
);
assert_eq!(
"#atest1v9hx7w36f46kcarfw3hkketwyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpq4w0mck/#atest1v46xsw36xe3rzde4xsmngefc8ycrjdrrxs6xgcfe8p3rjdf5v4jkgetpvv6rjdfjxuckgvrxqhdj5x/balance/#atest1d9khqw36x9zyxwfhgfpygv2pgc65gse4gy6rjs34gfzr2v69gy6y23zpggurjv2yx5m52sesu6r4y4",
key.to_string()
)
"#tnam1pyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqej6juv/#\
tnam1pd43w4r5azgff3zd4x9e2nhdatzf2fcapusvp8s9/balance/#\
tnam1qqwuj7aart6ackjfkk7486jwm2ufr4t7cq4535u4",
key.to_string()
)
}

#[test]
Expand All @@ -190,9 +192,10 @@ mod test {
let token = token(&DAI_ERC20_ETH_ADDRESS);
let key = minted_balance_key(&token);
assert_eq!(
"#atest1v9hx7w36f46kcarfw3hkketwyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpq4w0mck/#atest1v46xsw36xe3rzde4xsmngefc8ycrjdrrxs6xgcfe8p3rjdf5v4jkgetpvv6rjdfjxuckgvrxqhdj5x/balance/minted",
key.to_string(),
)
"#tnam1pyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqej6juv/#\
tnam1pd43w4r5azgff3zd4x9e2nhdatzf2fcapusvp8s9/balance/minted",
key.to_string(),
)
}

#[test]
Expand Down
43 changes: 28 additions & 15 deletions core/src/types/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,42 +550,50 @@ impl Display for InternalAddress {

/// Temporary helper for testing
pub fn nam() -> Address {
Address::decode("atest1v4ehgw36x3prswzxggunzv6pxqmnvdj9xvcyzvpsggeyvs3cg9qnywf589qnwvfsg5erg3fkl09rg5").expect("The token address decoding shouldn't fail")
Address::decode("tnam1q99c37u38grkdcc2qze0hz4zjjd8zr3yucd3mzgz")
.expect("The token address decoding shouldn't fail")
}

/// Temporary helper for testing
pub fn btc() -> Address {
Address::decode("atest1v4ehgw36xdzryve5gsc52veeg5cnsv2yx5eygvp38qcrvd29xy6rys6p8yc5xvp4xfpy2v694wgwcp").expect("The token address decoding shouldn't fail")
Address::decode("tnam1qy7jxng788scr4fdqxqxtc2ze2guq5478cml9cd9")
.expect("The token address decoding shouldn't fail")
}

/// Temporary helper for testing
pub fn eth() -> Address {
Address::decode("atest1v4ehgw36xqmr2d3nx3ryvd2xxgmrq33j8qcns33sxezrgv6zxdzrydjrxveygd2yxumrsdpsf9jc2p").expect("The token address decoding shouldn't fail")
Address::decode("tnam1qyr9vd8ltunq72qc7pk58v7jdsedt4mggqqpxs03")
.expect("The token address decoding shouldn't fail")
}

/// Temporary helper for testing
pub fn dot() -> Address {
Address::decode("atest1v4ehgw36gg6nvs2zgfpyxsfjgc65yv6pxy6nwwfsxgungdzrggeyzv35gveyxsjyxymyz335hur2jn").expect("The token address decoding shouldn't fail")
Address::decode("tnam1qx6k4wau5t6m8g2hjq55fje2ynpvh5t27s8p3p0l")
.expect("The token address decoding shouldn't fail")
}

/// Temporary helper for testing
pub fn schnitzel() -> Address {
Address::decode("atest1v4ehgw36xue5xvf5xvuyzvpjx5un2v3k8qeyvd3cxdqns32p89rrxd6xx9zngvpegccnzs699rdnnt").expect("The token address decoding shouldn't fail")
Address::decode("tnam1q9euzsu2qfv4y6p0dqaga20n0u0yp8c3ec006yg2")
.expect("The token address decoding shouldn't fail")
}

/// Temporary helper for testing
pub fn apfel() -> Address {
Address::decode("atest1v4ehgw36gfryydj9g3p5zv3kg9znyd358ycnzsfcggc5gvecgc6ygs2rxv6ry3zpg4zrwdfeumqcz9").expect("The token address decoding shouldn't fail")
Address::decode("tnam1qxlmdmw2y6hzvjg34zca8r6d4s6zmtkhty8myzu4")
.expect("The token address decoding shouldn't fail")
}

/// Temporary helper for testing
pub fn kartoffel() -> Address {
Address::decode("atest1v4ehgw36gep5ysecxq6nyv3jg3zygv3e89qn2vp48pryxsf4xpznvve5gvmy23fs89pryvf5a6ht90").expect("The token address decoding shouldn't fail")
Address::decode("tnam1q87teqzjytwa9xd9qk8u558xxnrwuzdjzs7zvhzr")
.expect("The token address decoding shouldn't fail")
}

/// Temporary helper for testing
pub fn masp() -> Address {
Address::decode("atest1v4ehgw36xaryysfsx5unvve4g5my2vjz89p52sjxxgenzd348yuyyv3hg3pnjs35g5unvde4ca36y5").expect("The token address decoding shouldn't fail")
Address::decode("tnam1q9lm5pvkxhnw9wwwhu33vkvtylwfkn5kw53xwud8")
.expect("The token address decoding shouldn't fail")
}

/// Sentinel secret key to indicate a MASP source
Expand Down Expand Up @@ -653,9 +661,10 @@ pub mod tests {

#[test]
fn test_address_serde_serialize() {
let original_address = Address::decode("atest1v4ehgw36g56ngwpk8ppnzsf4xqeyvsf3xq6nxde5gseyys3nxgenvvfex5cnyd2rx9zrzwfctgx7sp").unwrap();
let expect =
"\"atest1v4ehgw36g56ngwpk8ppnzsf4xqeyvsf3xq6nxde5gseyys3nxgenvvfex5cnyd2rx9zrzwfctgx7sp\"";
let original_address =
Address::decode("tnam1q8j5s6xp55p05yznwnftkv3kr9gjtsw3nq7x6tw5")
.unwrap();
let expect = "\"tnam1q8j5s6xp55p05yznwnftkv3kr9gjtsw3nq7x6tw5\"";
let decoded_address: Address =
serde_json::from_str(expect).expect("could not read JSON");
assert_eq!(original_address, decoded_address);
Expand Down Expand Up @@ -743,22 +752,26 @@ pub mod testing {

/// A sampled established address for tests
pub fn established_address_1() -> Address {
Address::decode("atest1v4ehgw36g56ngwpk8ppnzsf4xqeyvsf3xq6nxde5gseyys3nxgenvvfex5cnyd2rx9zrzwfctgx7sp").expect("The token address decoding shouldn't fail")
Address::decode("tnam1q8j5s6xp55p05yznwnftkv3kr9gjtsw3nq7x6tw5")
.expect("The token address decoding shouldn't fail")
}

/// A sampled established address for tests
pub fn established_address_2() -> Address {
Address::decode("atest1v4ehgw36xezyzv33x56rws6zxccnwwzzgycy23p3ggur2d3ex56yxdejxerrysejx3rrxdfs44s9wu").expect("The token address decoding shouldn't fail")
Address::decode("tnam1q9k6y928edsh3wsw6xu9d92vwfhjcf8n2qn3g5y8")
.expect("The token address decoding shouldn't fail")
}

/// A sampled established address for tests
pub fn established_address_3() -> Address {
Address::decode("atest1v4ehgw36xcerywfsgsu5vsfeg3zy2v3egcenx32pggcrswzxg4zns3p5xv6rsvf4gvenqwpkdnnqsy").expect("The token address decoding shouldn't fail")
Address::decode("tnam1q93zjrvl48w798ena2cg3lhg6s6gzhpssc766yvs")
.expect("The token address decoding shouldn't fail")
}

/// A sampled established address for tests
pub fn established_address_4() -> Address {
Address::decode("atest1v4ehgw36gscrw333g3z5zvjzg4rrq3psxu6rqd2xxqc5gs35gerrs3pjgfprvdejxqunxs29t6p5s9").expect("The token address decoding shouldn't fail")
Address::decode("tnam1q8g8780290hs6p6qtuqaknlc62akwgyn4cj48tkq")
.expect("The token address decoding shouldn't fail")
}

/// Generate an arbitrary [`Address`] (established or implicit).
Expand Down
2 changes: 1 addition & 1 deletion documentation/dev/src/specs/ledger/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ paths:
"method": "abci_query",
"params":
{
"path": "value/#atest1v4ehgw36g4pyg3j9x3qnjd3cxgmyz3fk8qcrys3hxdp5xwfnx3zyxsj9xgunxsfjg5u5xvzyzrrqtn/public_key",
"path": "value/#tnam1q84ale9fdqn2u6qzku7vjdxuhc5n5t5up55q6fjk/public_key",
"prove": true,
},
}
Expand Down
2 changes: 1 addition & 1 deletion documentation/dev/src/specs/ledger/rpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ For example, to find if an established address exists on-chain, we can submit a

TODO document response types encoding after <https://github.com/anoma/namada/issues/439>

The Proof-of-Stake queries are built on top of the [read-only queries](#read-only-queries), where all the PoS data are stored under the [internal `PoS` address](../encoding.html#internaladdress), which is governed by its native validity predicate. The bech32m encoded address of the PoS account currently is `"atest1v9hx7w362pex7mmxyphkvgznw3skkefqyqszqgpqyqszqgpqyqszqgpqyqszqgpqyqszqgpqq8ylv7"`, in the storage keys below in place of `PoS`.
The Proof-of-Stake queries are built on top of the [read-only queries](#read-only-queries), where all the PoS data are stored under the [internal `PoS` address](../encoding.html#internaladdress), which is governed by its native validity predicate. The bech32m encoded address of the PoS account currently is `"tnam1qgqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqc8j2fp"`, in the storage keys below in place of `PoS`.

Note that in the query paths below (and in all storage keys in general), addresses are encoded with bech32m and prefixed with `#` character.

Expand Down
18 changes: 9 additions & 9 deletions genesis/dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ native_token = "NAM"
# Some tokens present at genesis.

[token.NAM]
address = "atest1v4ehgw36x3prswzxggunzv6pxqmnvdj9xvcyzvpsggeyvs3cg9qnywf589qnwvfsg5erg3fkl09rg5"
address = "tnam1q99c37u38grkdcc2qze0hz4zjjd8zr3yucd3mzgz"
denom = 6
vp = "vp_token"
[token.NAM.balances]
Expand All @@ -24,7 +24,7 @@ kp_gain_nom = "0.1"
locked_ratio_target_key = "0.6667"

[token.BTC]
address = "atest1v4ehgw36xdzryve5gsc52veeg5cnsv2yx5eygvp38qcrvd29xy6rys6p8yc5xvp4xfpy2v694wgwcp"
address = "tnam1qy7jxng788scr4fdqxqxtc2ze2guq5478cml9cd9"
denom = 8
vp = "vp_token"
[token.BTC.balances]
Expand All @@ -40,7 +40,7 @@ kp_gain_nom = "0.1"
locked_ratio_target_key = "0.6667"

[token.ETH]
address = "atest1v4ehgw36xqmr2d3nx3ryvd2xxgmrq33j8qcns33sxezrgv6zxdzrydjrxveygd2yxumrsdpsf9jc2p"
address = "tnam1qyr9vd8ltunq72qc7pk58v7jdsedt4mggqqpxs03"
denom = 18
vp = "vp_token"
[token.ETH.balances]
Expand All @@ -56,7 +56,7 @@ kp_gain_nom = "0.1"
locked_ratio_target_key = "0.6667"

[token.DOT]
address = "atest1v4ehgw36gg6nvs2zgfpyxsfjgc65yv6pxy6nwwfsxgungdzrggeyzv35gveyxsjyxymyz335hur2jn"
address = "tnam1qx6k4wau5t6m8g2hjq55fje2ynpvh5t27s8p3p0l"
denom = 10
vp = "vp_token"
[token.DOT.balances]
Expand All @@ -72,7 +72,7 @@ kp_gain_nom = "0.1"
locked_ratio_target_key = "0.6667"

[token.Schnitzel]
address = "atest1v4ehgw36xue5xvf5xvuyzvpjx5un2v3k8qeyvd3cxdqns32p89rrxd6xx9zngvpegccnzs699rdnnt"
address = "tnam1q9euzsu2qfv4y6p0dqaga20n0u0yp8c3ec006yg2"
denom = 6
vp = "vp_token"
[token.Schnitzel.balances]
Expand All @@ -88,7 +88,7 @@ kp_gain_nom = "0.1"
locked_ratio_target_key = "0.6667"

[token.Apfel]
address = "atest1v4ehgw36gfryydj9g3p5zv3kg9znyd358ycnzsfcggc5gvecgc6ygs2rxv6ry3zpg4zrwdfeumqcz9"
address = "tnam1qxlmdmw2y6hzvjg34zca8r6d4s6zmtkhty8myzu4"
denom = 6
vp = "vp_token"
[token.Apfel.balances]
Expand All @@ -104,7 +104,7 @@ kp_gain_nom = "0.1"
locked_ratio_target_key = "0.6667"

[token.Kartoffel]
address = "atest1v4ehgw36gep5ysecxq6nyv3jg3zygv3e89qn2vp48pryxsf4xpznvve5gvmy23fs89pryvf5a6ht90"
address = "tnam1q87teqzjytwa9xd9qk8u558xxnrwuzdjzs7zvhzr"
public_key = ""
denom = 6
vp = "vp_token"
Expand All @@ -130,7 +130,7 @@ vp = "vp_user"
vp = "vp_user"

[established.masp]
address = "atest1v4ehgw36xaryysfsx5unvve4g5my2vjz89p52sjxxgenzd348yuyyv3hg3pnjs35g5unvde4ca36y5"
address = "tnam1q9lm5pvkxhnw9wwwhu33vkvtylwfkn5kw53xwud8"
vp = "vp_masp"

[implicit.Daewon]
Expand Down Expand Up @@ -188,7 +188,7 @@ pos_gain_d = "0.1"
max_signatures_per_transaction = 15

[parameters.minimum_gas_price]
"atest1v4ehgw36x3prswzxggunzv6pxqmnvdj9xvcyzvpsggeyvs3cg9qnywf589qnwvfsg5erg3fkl09rg5" = "0.000001"
"tnam1q99c37u38grkdcc2qze0hz4zjjd8zr3yucd3mzgz" = "0.000001"

# Proof of stake parameters.
[pos_params]
Expand Down
Loading

0 comments on commit 49d7b58

Please sign in to comment.