refactor mint endpoint to use query parameters and improve test script accordingly #6
| @ -69,15 +69,16 @@ for n in $(seq 1 $num_nodes); do | |||||||
|                detee/hacker-challenge:test |                detee/hacker-challenge:test | ||||||
| done | done | ||||||
| 
 | 
 | ||||||
|  | echo "Initialing test.." | ||||||
|  | sleep 4; | ||||||
|  | 
 | ||||||
| echo "Running the test mint" | echo "Running the test mint" | ||||||
| for n in {1..20}; do | for n in {1..20}; do | ||||||
|     node_port=$((31300 + n)) |     node_port=$((31300 + n)) | ||||||
|     curl -X POST "127.0.0.1:${node_port}/mint" \ |     curl -X POST "127.0.0.1:${node_port}/mint?address=EZT16iP1SQVUFf1AJN6oiE5BZPnyBUqaKDkZ4oZRsvhR" --connect-timeout 5 2> /dev/null | ||||||
|          --json '{"wallet": "EZT16iP1SQVUFf1AJN6oiE5BZPnyBUqaKDkZ4oZRsvhR"}' \ |  | ||||||
|          --connect-timeout 5 2> /dev/null |  | ||||||
|     echo "" |  | ||||||
| done | done | ||||||
| 
 | 
 | ||||||
|  | # curl -X POST "127.0.0.1:31303/mint?address=EZT16iP1SQVUFf1AJN6oiE5BZPnyBUqaKDkZ4oZRsvhR" --connect-timeout 5 | ||||||
| # curl 127.0.0.1:31303/metrics | # curl 127.0.0.1:31303/metrics | ||||||
| # curl -X POST 127.0.0.1:31303/mint -d '{"wallet": "EZT16iP1SQVUFf1AJN6oiE5BZPnyBUqaKDkZ4oZRsvhR"}' -H 'Content-Type: application/json' | # curl -X POST 127.0.0.1:31303/mint -d '{"wallet": "EZT16iP1SQVUFf1AJN6oiE5BZPnyBUqaKDkZ4oZRsvhR"}' -H 'Content-Type: application/json' | ||||||
| # docker run --name dthc0 --network dthc -d --ip 172.18.0.2 --env NODE_IP="172.18.0.2" --env INIT_NODES="172.18.0.5 172.18.0.3 172.18.0.4" --volume /tmp/dthc0:/challenge/main --publish 31300:31372 --device /dev/sgx/provision --device /dev/sgx/enclave detee/hacker-challenge:test | # docker run --name dthc0 --network dthc -d --ip 172.18.0.2 --env NODE_IP="172.18.0.2" --env INIT_NODES="172.18.0.5 172.18.0.3 172.18.0.4" --volume /tmp/dthc0:/challenge/main --publish 31300:31372 --device /dev/sgx/provision --device /dev/sgx/enclave detee/hacker-challenge:test | ||||||
|  | |||||||
| @ -56,16 +56,16 @@ async fn get_nodes(state: web::Data<Arc<State>>) -> HttpResponse { | |||||||
| 
 | 
 | ||||||
| #[derive(Deserialize)] | #[derive(Deserialize)] | ||||||
| struct MintReq { | struct MintReq { | ||||||
|     wallet: String, |     address: String, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[post("/mint")] | #[post("/mint")] | ||||||
| async fn mint( | async fn mint( | ||||||
|     state: web::Data<Arc<State>>, |     state: web::Data<Arc<State>>, | ||||||
|     sol_client: web::Data<Arc<SolClient>>, |     sol_client: web::Data<Arc<SolClient>>, | ||||||
|     req: web::Json<MintReq>, |     req: web::Query<MintReq>, | ||||||
| ) -> impl Responder { | ) -> impl Responder { | ||||||
|     let recipient = req.into_inner().wallet; |     let recipient = req.into_inner().address; | ||||||
|     state.increase_mint_requests().await; |     state.increase_mint_requests().await; | ||||||
| 
 | 
 | ||||||
|     if state.is_minting() { |     if state.is_minting() { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user