1
1
use anyhow:: Context ;
2
+ use aptos_sdk:: rest_client:: {
3
+ aptos_api_types:: { Address , EntryFunctionId , IdentifierWrapper , MoveModuleId , ViewRequest } ,
4
+ } ;
5
+ use aptos_sdk:: types:: account_address:: AccountAddress ;
2
6
use movement_client:: {
3
7
coin_client:: CoinClient ,
4
8
rest_client:: Client ,
5
9
types:: LocalAccount ,
6
10
} ;
7
- use aptos_sdk:: rest_client:: aptos_api_types:: { ViewRequest , EntryFunctionId , MoveModuleId , Address , IdentifierWrapper } ;
8
- use movement_client:: types:: account_address:: AccountAddress ;
9
- use std:: str:: FromStr ;
10
11
use once_cell:: sync:: Lazy ;
12
+ use std:: str:: FromStr ;
11
13
use url:: Url ;
12
14
use reqwest;
13
15
@@ -17,7 +19,11 @@ static SUZUKA_CONFIG: Lazy<movement_config::Config> = Lazy::new(|| {
17
19
config
18
20
} ) ;
19
21
20
- static NODE_URL : Lazy < Url > = Lazy :: new ( || {
22
+ #[ tokio:: main]
23
+ async fn main ( ) -> Result < ( ) , anyhow:: Error > {
24
+ println ! ( "Starting e2e_ggp_deprecation test..." ) ;
25
+
26
+ // Connect to the node
21
27
let node_connection_address = SUZUKA_CONFIG
22
28
. execution_config
23
29
. maptos_config
@@ -30,19 +36,11 @@ static NODE_URL: Lazy<Url> = Lazy::new(|| {
30
36
. client
31
37
. maptos_rest_connection_port
32
38
. clone ( ) ;
33
-
34
39
let node_connection_url = format ! ( "http://{}:{}" , node_connection_address, node_connection_port) ;
35
- Url :: parse ( node_connection_url. as_str ( ) ) . unwrap ( )
36
- } ) ;
37
-
38
-
39
-
40
- #[ tokio:: main]
41
- async fn main ( ) -> Result < ( ) , anyhow:: Error > {
42
- println ! ( "Starting e2e_ggp_deprecation test..." ) ;
43
40
44
- println ! ( "Connecting to node at: {}" , NODE_URL . as_str( ) ) ;
45
- let rest_client = Client :: new ( NODE_URL . clone ( ) ) ;
41
+ println ! ( "Connecting to node at: {}" , node_connection_url) ;
42
+
43
+ let rest_client = Client :: new ( Url :: from_str ( & node_connection_url) ?) ;
46
44
let coin_client = CoinClient :: new ( & rest_client) ;
47
45
48
46
println ! ( "Attempting to get chain info..." ) ;
@@ -54,73 +52,80 @@ async fn main() -> Result<(), anyhow::Error> {
54
52
println ! ( "Created test accounts" ) ;
55
53
println ! ( "Sender address: {}, Beneficiary address: {}" , sender. address( ) , beneficiary. address( ) ) ;
56
54
57
- // Fund the sender account using the faucet directly
58
- println ! ( "Funding sender account via faucet..." ) ;
55
+ // Fund the sender account using the testnet faucet
56
+ println ! ( "Funding sender account via testnet faucet..." ) ;
59
57
60
58
let faucet_url = if let Ok ( override_url) = std:: env:: var ( "MOVEMENT_FAUCET_URL" ) {
61
59
override_url
62
60
} else {
63
- "https://faucet.movementnetwork .xyz" . to_string ( )
61
+ "https://faucet.testnet.movementinfra .xyz" . to_string ( )
64
62
} ;
65
63
66
64
// Try different approaches to match what the faucet expects
67
65
let client = reqwest:: Client :: new ( ) ;
68
- let pub_key_hex = hex:: encode ( sender. public_key ( ) . to_bytes ( ) ) ;
69
66
70
- // First try POST with pub_key (preferred)
71
- let mut funded = false ;
67
+ // First try GET with address (some faucets prefer this)
72
68
let response = client
73
- . post ( & format ! ( "{}/mint" , faucet_url) )
74
- . form ( & [
75
- ( "pub_key " , pub_key_hex . clone ( ) ) ,
69
+ . get ( & format ! ( "{}/mint" , faucet_url) )
70
+ . query ( & [
71
+ ( "address " , sender . address ( ) . to_string ( ) ) ,
76
72
( "amount" , "1000000" . to_string ( ) ) ,
77
73
( "return_txns" , "true" . to_string ( ) ) ,
78
74
] )
79
75
. send ( )
80
76
. await
81
- . context ( "Failed to send faucet POST request with pub_key" ) ?;
77
+ . context ( "Failed to send faucet GET request" ) ?;
78
+
82
79
let status = response. status ( ) ;
83
- if status. is_success ( ) {
84
- funded = true ;
85
- } else {
86
- let error_text = response. text ( ) . await . unwrap_or_default ( ) ;
87
- println ! ( "[WARN] Faucet POST(pub_key) failed {}: {}" , status, error_text) ;
88
- // Try GET with address as fallback
80
+ println ! ( "Faucet GET response status: {}" , status) ;
81
+
82
+ if !status. is_success ( ) {
83
+ // If GET fails, try POST with form data
84
+ println ! ( "GET request failed with status {}, trying POST with form data..." , status) ;
89
85
let response = client
90
- . get ( & format ! ( "{}/mint" , faucet_url) )
91
- . query ( & [
86
+ . post ( & format ! ( "{}/mint" , faucet_url) )
87
+ . form ( & [
92
88
( "address" , sender. address ( ) . to_string ( ) ) ,
93
89
( "amount" , "1000000" . to_string ( ) ) ,
94
90
( "return_txns" , "true" . to_string ( ) ) ,
95
91
] )
96
92
. send ( )
97
93
. await
98
- . context ( "Failed to send faucet GET request with address " ) ?;
94
+ . context ( "Failed to send faucet POST request" ) ?;
99
95
let status = response. status ( ) ;
100
- if status. is_success ( ) {
101
- funded = true ;
102
- } else {
96
+ println ! ( "Faucet POST response status: {}" , status) ;
97
+ if !status. is_success ( ) {
103
98
let error_text = response. text ( ) . await . unwrap_or_default ( ) ;
104
99
return Err ( anyhow:: anyhow!( "Faucet request failed with status {}: {}" , status, error_text) ) ;
105
100
}
106
101
}
107
102
108
- if funded {
109
- println ! ( "Sender account funded request accepted by faucet" ) ;
110
- }
103
+ // Get the response body to see what the faucet actually returned
104
+ let response_text = response . text ( ) . await . unwrap_or_default ( ) ;
105
+ println ! ( "Faucet response body: {}" , response_text ) ;
111
106
112
- // Wait until the account exists on-chain (poll a few times)
107
+ println ! ( "Sender account funded request accepted by faucet" ) ;
108
+
109
+ // Wait longer for account creation and add more debugging
110
+ println ! ( "Waiting for account to appear on-chain..." ) ;
113
111
let mut created = false ;
114
- for attempt in 1 ..=10 {
112
+ for attempt in 1 ..=20 { // Increased from 10 to 20 attempts
113
+ println ! ( "Checking account existence... attempt {}/20" , attempt) ;
115
114
match rest_client. get_account ( sender. address ( ) ) . await {
116
115
Ok ( account_info) => {
117
- println ! ( "Account now exists on-chain with sequence {} (attempt {})" , account_info. inner( ) . sequence_number, attempt) ;
116
+ println ! ( "✅ Account now exists on-chain!" ) ;
117
+ println ! ( " Sequence number: {}" , account_info. inner( ) . sequence_number) ;
118
+ println ! ( " Authentication key: {:?}" , account_info. inner( ) . authentication_key) ;
119
+ println ! ( " Created in attempt {}" , attempt) ;
118
120
created = true ;
119
121
break ;
120
122
}
121
- Err ( _) => {
122
- println ! ( "Waiting for account creation on-chain... attempt {}" , attempt) ;
123
- tokio:: time:: sleep ( tokio:: time:: Duration :: from_millis ( 500 ) ) . await ;
123
+ Err ( e) => {
124
+ println ! ( "❌ Account not found yet (attempt {}/20): {}" , attempt, e) ;
125
+ if attempt < 20 {
126
+ println ! ( "Waiting 1 second before next check..." ) ;
127
+ tokio:: time:: sleep ( tokio:: time:: Duration :: from_secs ( 1 ) ) . await ; // Increased from 500ms to 1s
128
+ }
124
129
}
125
130
}
126
131
}
@@ -129,11 +134,11 @@ async fn main() -> Result<(), anyhow::Error> {
129
134
return Err ( anyhow:: anyhow!( "Sender account not found on-chain after faucet funding" ) ) ;
130
135
}
131
136
132
- println ! ( "Sender account funded successfully via faucet" ) ;
137
+ println ! ( "Sender account funded successfully via testnet faucet" ) ;
133
138
134
139
// Create the beneficiary account (just create, no funding needed for this test)
135
140
println ! ( "Creating beneficiary account..." ) ;
136
- // Created locally; on-chain creation occurs on first transfer
141
+ // For now, just create the account locally - it will be created when first transaction is sent to it
137
142
138
143
// Test 1: Verify new fee collection mechanism
139
144
println ! ( "=== Test 1: Verifying new fee collection mechanism ===" ) ;
0 commit comments