refactor mint endpoint to use query parameters and improve test script accordingly
This commit is contained in:
		
							parent
							
								
									855e9ab28b
								
							
						
					
					
						commit
						1a897d780f
					
				| @ -69,15 +69,16 @@ for n in $(seq 1 $num_nodes); do | ||||
|                detee/hacker-challenge:test | ||||
| done | ||||
| 
 | ||||
| echo "Initialing test.." | ||||
| sleep 4; | ||||
| 
 | ||||
| echo "Running the test mint" | ||||
| for n in {1..20}; do | ||||
|     node_port=$((31300 + n)) | ||||
|     curl -X POST "127.0.0.1:${node_port}/mint" \ | ||||
|          --json '{"wallet": "EZT16iP1SQVUFf1AJN6oiE5BZPnyBUqaKDkZ4oZRsvhR"}' \ | ||||
|          --connect-timeout 5 2> /dev/null | ||||
|     echo "" | ||||
|     curl -X POST "127.0.0.1:${node_port}/mint?address=EZT16iP1SQVUFf1AJN6oiE5BZPnyBUqaKDkZ4oZRsvhR" --connect-timeout 5 2> /dev/null | ||||
| done | ||||
| 
 | ||||
| # curl -X POST "127.0.0.1:31303/mint?address=EZT16iP1SQVUFf1AJN6oiE5BZPnyBUqaKDkZ4oZRsvhR" --connect-timeout 5 | ||||
| # curl 127.0.0.1:31303/metrics | ||||
| # 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 | ||||
|  | ||||
| @ -56,16 +56,16 @@ async fn get_nodes(state: web::Data<Arc<State>>) -> HttpResponse { | ||||
| 
 | ||||
| #[derive(Deserialize)] | ||||
| struct MintReq { | ||||
|     wallet: String, | ||||
|     address: String, | ||||
| } | ||||
| 
 | ||||
| #[post("/mint")] | ||||
| async fn mint( | ||||
|     state: web::Data<Arc<State>>, | ||||
|     sol_client: web::Data<Arc<SolClient>>, | ||||
|     req: web::Json<MintReq>, | ||||
|     req: web::Query<MintReq>, | ||||
| ) -> impl Responder { | ||||
|     let recipient = req.into_inner().wallet; | ||||
|     let recipient = req.into_inner().address; | ||||
|     state.increase_mint_requests().await; | ||||
| 
 | ||||
|     if state.is_minting() { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user