Skip to content

Commit 92ddb26

Browse files
committed
Merge branch 'andygolay/framework-client-tests' of https://github.com/movementlabsxyz/movement into andygolay/framework-client-tests
2 parents 7bf3b01 + 9f08459 commit 92ddb26

File tree

3 files changed

+16
-138
lines changed

3 files changed

+16
-138
lines changed

protocol-units/bridge/integration-tests/README.md

+13-97
Original file line numberDiff line numberDiff line change
@@ -7,122 +7,38 @@ The client integration tests for the framework bridge modules are in `tests`:
77

88
In order to successfully run the tests against a local Suzuka node, the core resource account `0xA550C18` needs to be set to the same private key generated in `config.json`.
99

10-
## Steps to configure core resource account for signing in tests:
10+
## Steps to run integration tests
1111

12-
1. From the root of the `movement` repository, run the local Suzuka node:
12+
1. Navigate to the root of the `movement` repo, checkout the `andygolay/framework-client-tests` branch, and start a local Suzuka node:
1313

1414
```
1515
CELESTIA_LOG_LEVEL=FATAL CARGO_PROFILE=release CARGO_PROFILE_FLAGS=--release nix develop --extra-experimental-features nix-command --extra-experimental-features flakes --command bash -c "just bridge native build.setup.eth-local.celestia-local --keep-tui"
1616
```
1717

18-
(You'll need Nix and Movement CLI if you don't already have them installed.)
18+
Note, if you have any `.movement` directories present, e.g. when re-running tests, the directories must be deleted before starting the node.
1919

20-
This will generate a `.movement` dir in the project root containing a `config.json` with a `maptos_private_key` of `0x1`:
21-
```
22-
"maptos_private_key": "0x0000000000000000000000000000000000000000000000000000000000000001",
23-
```
24-
25-
There will also be a `config.yaml` that looks something like:
20+
2. In the generated `.movement` directory, there will be a `config.yaml`. In that file, change `f90391c81027f03cdea491ed8b36ffaced26b6df208a9b569e5baf2590eb9b16` to `0xA550C18` so the file looks like:
2621

2722
```
2823
---
2924
profiles:
3025
default:
31-
network: Custom
32-
private_key: "0x5754431205b8abc443a7a877a70d6e5e67eba8e5e40b0436bff5a9b6ab4a7887"
33-
public_key: "0x2b8c073bf4c091649d8fb5c275cacc6c8cf8cb6baaf0d7dffc47216011b6a27d"
34-
account: e813b12fc00bed33b54b5652c3bb1cbf12a33080aba9cd12d919b6d65cec6115
35-
rest_url: "http://localhost:30731/v1"
36-
faucet_url: "http://localhost:30732/"
37-
```
38-
39-
2. Init a profile with the `0x1` private key. Here we init a profile named `local_root`:
40-
41-
```
42-
movement init --profile local_root --rest-url http://localhost:30731/v1 --private-key 0x0000000000000000000000000000000000000000000000000000000000000001 --encoding hex --network custom
43-
```
44-
45-
3. In `config.yaml` replace the `account` of `local_root` with `000000000000000000000000000000000000000000000000000000000a550c18` and skip the faucet step by pressing Enter when prompted. Your `config.yaml` will look like this:
46-
47-
```
48-
---
49-
profiles:
50-
default:
51-
network: Custom
52-
private_key: "<some-private-key>"
53-
public_key: "0x2b8c073bf4c091649d8fb5c275cacc6c8cf8cb6baaf0d7dffc47216011b6a27d"
54-
account: e813b12fc00bed33b54b5652c3bb1cbf12a33080aba9cd12d919b6d65cec6115
55-
rest_url: "http://localhost:30731/v1"
56-
faucet_url: "http://localhost:30732/"
57-
local_root:
5826
network: Custom
5927
private_key: "0x0000000000000000000000000000000000000000000000000000000000000001"
6028
public_key: "0x4cb5abf6ad79fbf5abbccafcc269d85cd2651ed4b885b5869f241aedf0a5ba29"
61-
account: 000000000000000000000000000000000000000000000000000000000a550c18
62-
rest_url: "http://localhost:30731/v1"
63-
```
29+
account: "0xA550C18"
30+
rest_url: "http://0.0.0.0:30731/"
31+
faucet_url: "http://0.0.0.0:30732/"
32+
```
6433

65-
4. List the contents of the `0xa550c18` account:
34+
3. Run each set of Movement client tests:
6635

36+
L1 Move to L2 Move:
6737
```
68-
movement account list --account 0xA550C18
38+
rust_backtrace=1 cargo test --test client_l1move_l2move -- --nocapture --test-threads=1
6939
```
7040

71-
You should see a large number of `AptosCoin` held by the account:
72-
73-
```
74-
{
75-
"0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>": {
76-
"coin": {
77-
"value": "18446743973709450015"
78-
},
79-
"deposit_events": {
80-
"counter": "1",
81-
"guid": {
82-
"id": {
83-
"addr": "0xa550c18",
84-
"creation_num": "2"
85-
}
86-
}
87-
},
88-
"frozen": false,
89-
"withdraw_events": {
90-
"counter": "1",
91-
"guid": {
92-
"id": {
93-
"addr": "0xa550c18",
94-
"creation_num": "3"
95-
}
96-
}
97-
}
98-
}
99-
}
41+
L2 Move to L1 Move:
10042
```
101-
102-
This large number of gas coins signifies that this is the core resource account.
103-
104-
5. Verify that you control the core resources signer by transferring gas tokens to your default account:
105-
106-
```
107-
movement account transfer --profile local_root --amount 100 --account e813b12fc00bed33b54b5652c3bb1cbf12a33080aba9cd12d919b6d65cec6115
108-
```
109-
110-
You'll be prompted to submit a transaction. After doing so, if the transaction is successful, you'll get a success message and transaction result.
111-
112-
## Steps to run client integration tests
113-
114-
Now that the core resource signer is configured, you can run the client integration tests.
115-
116-
There are two scripts in `protocol-units/bridge/move-modules`, one for enabling the Atomic Bridge feature flag and one for updating bridge operator.
117-
118-
1. Compile the scripts:
119-
120-
```
121-
movement move compile --package-dir protocol-units/bridge/move-modules
122-
```
123-
124-
2. Run the `enable_bridge_feature` script:
125-
43+
rust_backtrace=1 cargo test --test client_l2move_l1move -- --nocapture --test-threads=1
12644
```
127-
movement move run-script --compiled-script-path protocol-units/bridge/move-modules/build/bridge-modules/bytecode_scripts/enable_bridge_feature.mv --profile local_root
128-
```

protocol-units/bridge/integration-tests/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ impl Default for EthToMovementCallArgs {
6565
bridge_transfer_id.extend_from_slice(random_suffix.as_bytes());
6666

6767
Self {
68+
// Dummy valid EIP-55 address used in framework modules
6869
initiator: b"32Be343B94f860124dC4fEe278FDCBD38C102D88".to_vec(),
70+
// Dummy recipient address
6971
recipient: MovementAddress(AccountAddress::new(*b"0x00000000000000000000000000face")),
7072
// Convert to [u8; 32] with explicit type annotation
7173
bridge_transfer_id: MovementHash(

protocol-units/bridge/integration-tests/tests/client_l1move_l2move.rs

+1-41
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,10 @@ use tracing::info;
2727
async fn test_movement_client_lock_transfer(
2828
) -> Result<(), anyhow::Error> {
2929
let _ = tracing_subscriber::fmt().with_max_level(tracing::Level::DEBUG).try_init();
30-
31-
let _ = tracing_subscriber::fmt().with_max_level(tracing::Level::DEBUG).try_init();
32-
3330
MovementClientFramework::bridge_setup_scripts().await?;
34-
3531
let config: Config = Config::suzuka();
36-
3732
let (mut mvt_client_harness, config) = TestHarnessFramework::new_with_suzuka(config).await;
38-
3933
let args = EthToMovementCallArgs::default();
40-
4134
let test_result = async {
4235
let coin_client = CoinClient::new(&mvt_client_harness.rest_client);
4336
let movement_client_signer = mvt_client_harness.movement_client.signer();
@@ -86,7 +79,6 @@ async fn test_movement_client_lock_transfer(
8679
#[tokio::test]
8780
async fn test_movement_client_complete_transfer(
8881
) -> Result<(), anyhow::Error> {
89-
let _ = tracing_subscriber::fmt().with_max_level(tracing::Level::DEBUG).try_init();
9082
let _ = tracing_subscriber::fmt().with_max_level(tracing::Level::DEBUG).try_init();
9183
MovementClientFramework::bridge_setup_scripts().await?;
9284
let config: Config = Config::suzuka();
@@ -100,6 +92,7 @@ async fn test_movement_client_complete_transfer(
10092
faucet_client.fund(movement_client_signer.address(), 100_000_000).await?;
10193
faucet_client.fund(AccountAddress::from_hex_literal("0xface")?, 100_000_000).await?;
10294
faucet_client.fund(AccountAddress::from_hex_literal("0x1")?, 100_000_000).await?;
95+
// This address is the recipient in test_movement_client_complete_transfer, so it needs an AptosCoin store
10396
faucet_client.fund(AccountAddress::from_hex_literal("0x3078303030303030303030303030303030303030303030303030303066616365")?, 100_000_000).await?;
10497

10598
}
@@ -177,17 +170,10 @@ async fn test_movement_client_complete_transfer(
177170
async fn test_movement_client_abort_transfer(
178171
) -> Result<(), anyhow::Error> {
179172
let _ = tracing_subscriber::fmt().with_max_level(tracing::Level::DEBUG).try_init();
180-
181-
let _ = tracing_subscriber::fmt().with_max_level(tracing::Level::DEBUG).try_init();
182-
183173
MovementClientFramework::bridge_setup_scripts().await?;
184-
185174
let config: Config = Config::suzuka();
186-
187175
let (mut mvt_client_harness, config) = TestHarnessFramework::new_with_suzuka(config).await;
188-
189176
let args = EthToMovementCallArgs::default();
190-
191177
let test_result = async {
192178
let coin_client = CoinClient::new(&mvt_client_harness.rest_client);
193179
let movement_client_signer = mvt_client_harness.movement_client.signer();
@@ -266,32 +252,6 @@ async fn test_movement_client_abort_transfer(
266252

267253
test_result
268254
}
269-
#[tokio::test]
270-
async fn test_eth_client_should_build_and_fetch_accounts() {
271-
let config = Config::default();
272-
let (eth_client_harness, _config, _anvil) = TestHarness::new_only_eth(config).await;
273-
274-
let expected_accounts = [
275-
address!("f39fd6e51aad88f6f4ce6ab8827279cfffb92266"),
276-
address!("70997970c51812dc3a010c7d01b50e0d17dc79c8"),
277-
address!("3c44cdddb6a900fa2b585dd299e03d12fa4293bc"),
278-
address!("90f79bf6eb2c4f870365e785982e1f101e93b906"),
279-
address!("15d34aaf54267db7d7c367839aaf71a00a2c6a65"),
280-
address!("9965507d1a55bcc2695c58ba16fb37d819b0a4dc"),
281-
address!("976ea74026e726554db657fa54763abd0c3a0aa9"),
282-
address!("14dc79964da2c08b23698b3d3cc7ca32193d9955"),
283-
address!("23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f"),
284-
address!("a0ee7a142d267c1f36714e4a8f75612f20a79720"),
285-
];
286-
287-
let provider = eth_client_harness.rpc_provider().await;
288-
let accounts = provider.get_accounts().await.expect("Failed to get accounts");
289-
assert_eq!(accounts.len(), expected_accounts.len());
290-
291-
for (account, expected) in accounts.iter().zip(expected_accounts.iter()) {
292-
assert_eq!(account, expected);
293-
}
294-
}
295255

296256
#[tokio::test]
297257
async fn test_eth_client_should_deploy_initiator_contract() {

0 commit comments

Comments
 (0)