Skip to content

Commit

Permalink
test in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
NanezX committed Nov 1, 2023
1 parent be3c832 commit e19b252
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 17 deletions.
103 changes: 103 additions & 0 deletions subgraph/a.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
[
{
"address": "0x9e545e3c0baab3e08cdfd552c960a1050f373042",
"topics": [
"0x17a5c0f3785132a57703932032f6863e7920434150aa1dc940e567b440fdce1f"
],
"data": "0x0000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc0000000000000000000000009e545e3c0baab3e08cdfd552c960a1050f3730420000000000000000000000000000000000000000000000000000000000000003bc19bc43697850ba8771ef9683bc0a252b3f647ca2062b75e68c205f2b17572800000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c80000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000053444835ec5800000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000005000000000000000000000000a82ff9afd8f496c3d6ac40e2a0f282e47488cfc900000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000006ebaf8377a66cc56000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000053444835ec58000000000000000000000000000000000000000000000000000000000000000000050000000000000000000000001613beb3b2c4f22ee086b2b38c1476a3ce7f78e800000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000006ebaf8377a66cc5600000000000000000000000000000000000000000000003635c9adc5dea0000000000000000000000000000000000000000000000000000053444835ec580000",
"block_hash": "0xc04cf61e68f7240831cca36baca91569bc870556d761dea5653bd83d611729f9",

"block_number": 59,

"transaction_hash": "0x3a3c3a6b1c0b67143a9549e79398107de92c93786ff152825d206bd225ebaeb5",
"transaction_index": 0,
"log_index": 0,
"transaction_log_index": "None",
"log_type": "None",
"removed": false
},
{
"address": "0x9e545e3c0baab3e08cdfd552c960a1050f373042",
"topics": [
"0x219a030b7ae56e7bea2baab709a4a45dc174a1f85e57730e5cb395bc32962542"
],
"data":
"0x0000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000053444835ec58000000000000000000000000000000000000000000000000000053444835ec580000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000026000000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e6e340d132b5f46d1e472debcd681b2abc16e57e000000000000000000000000c3e53f4d16ae77db1c982e75a937b9f60fe63690000000000000000000000000da1a2e33bd9e8ae3641a61ab72f137e61a7edf6e00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a82ff9afd8f496c3d6ac40e2a0f282e47488cfc900000000000000000000000000000000000000000000000000000000000000x0000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000053444835ec58000000000000000000000000000000000000000000000000000053444835ec580000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000026000000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e6e340d132b5f46d1e472debcd681b2abc16e57e000000000000000000000000c3e53f4d16ae77db1c982e75a937b9f60fe63690000000000000000000000000da1a2e33bd9e8ae3641a61ab72f137e61a7edf6e00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a82ff9afd8f496c3d6ac40e2a0f282e47488cfc900000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000006ebaf8377a66cc5600000000000000000000000000000000000000000000000000000000000000010000000000000000000000001613beb3b2c4f22ee086b2b38c1476a3ce7f78e800000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000006ebaf8377a66cc5600000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000006ebaf8377a66cc5600000000000000000000000000000000000000000000000000000000000000010000000000000000000000001613beb3b2c4f22ee086b2b38c1476a3ce7f78e800000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000006ebaf8377a66cc560000000000000000000000000000000000000000000000000000000000000000",
"block_hash":
"0xc04cf61e68f7240831cca36baca91569bc870556d761dea5653bd83d611729f9"
,
"block_number": 59,
"transaction_hash":
"0x3a3c3a6b1c0b67143a9549e79398107de92c93786ff152825d206bd225ebaeb5",
"transaction_index": 0,
"log_index": 1,
"transaction_log_index": "None",
"log_type": "None",
"removed": false
},
{
"address": "0x1613beb3b2c4f22ee086b2b38c1476a3ce7f78e8",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000009e545e3c0baab3e08cdfd552c960a1050f373042",
"0x0000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc"
],
"data":
"0x00000000000000000000000000000000000000000000000053444835ec580000",
"block_hash":
"0xc04cf61e68f7240831cca36baca91569bc870556d761dea5653bd83d611729f9",
"block_number": 59,
"transaction_hash":
"0x3a3c3a6b1c0b67143a9549e79398107de92c93786ff152825d206bd225ebaeb5",
"transaction_index": 0,
"log_index": 2,
"transaction_log_index": "None",
"log_type": "None",
"removed": false
},
{
"address": "0xa82ff9afd8f496c3d6ac40e2a0f282e47488cfc9",
"topics": [
"0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925",
"0x0000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc",
"0x0000000000000000000000009e545e3c0baab3e08cdfd552c960a1050f373042"
],
"data":
"0x00000000000000000000000000000000000000000000021dc69c8184c5e80000",
"block_hash":
"0xc04cf61e68f7240831cca36baca91569bc870556d761dea5653bd83d611729f9"
,
"block_number": 59,
"transaction_hash":
"0x3a3c3a6b1c0b67143a9549e79398107de92c93786ff152825d206bd225ebaeb5"
,
"transaction_index": 0,
"log_index": 3,
"transaction_log_index": "None",
"log_type": "None",
"removed": false
},
{
"address": "0xa82ff9afd8f496c3d6ac40e2a0f282e47488cfc9",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000003c44cdddb6a900fa2b585dd299e03d12fa4293bc",
"0x0000000000000000000000009e545e3c0baab3e08cdfd552c960a1050f373042"
],
"data":
"0x00000000000000000000000000000000000000000000000053444835ec580000"
,
"block_hash":
"0xc04cf61e68f7240831cca36baca91569bc870556d761dea5653bd83d611729f9"
,
"block_number": 59,
"transaction_hash":
"0x3a3c3a6b1c0b67143a9549e79398107de92c93786ff152825d206bd225ebaeb5"
,
"transaction_index": 0,
"log_index": 4,
"transaction_log_index": "None",
"log_type": "None",
"removed": false
}
]
36 changes: 20 additions & 16 deletions subgraph/tests/entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2728,6 +2728,9 @@ async fn token_vault_take_order_entity_take_order_test() -> anyhow::Result<()> {
let token_vault_take_order_a_id = format!("{}-{}", take_order_entity, token_vault_input);
let token_vault_take_order_b_id = format!("{}-{}", take_order_entity, token_vault_output);

// Wait for Subgraph sync
wait().await?;

let resp_a = Query::token_vault_take_order(&token_vault_take_order_a_id).await?;
let resp_b = Query::token_vault_take_order(&token_vault_take_order_b_id).await?;

Expand Down Expand Up @@ -2844,6 +2847,12 @@ async fn take_order_entity_take_order_test() -> anyhow::Result<()> {
)
.await?;

let vault_balance_alice: U256 = orderbook
.vault_balance(alice.address(), token_output.address(), vault_id)
.call()
.await?;
println!("vault_balance_alice_0: {}", vault_balance_alice);

// Take the order
let take_order_func = orderbook
.connect(&bob)
Expand All @@ -2858,23 +2867,15 @@ async fn take_order_entity_take_order_test() -> anyhow::Result<()> {

let block_data = get_block_data(&take_order_tx_hash).await?;

let vault_balance_alice: U256 = orderbook
.vault_balance(alice.address(), token_output.address(), vault_id)
.call()
.await?;
println!("vault_balance_alice_1: {}", vault_balance_alice);

// Using index 0 since only one take order was made in this tx
let take_order_entity = format!("{:?}-{}", take_order_tx_hash, 0);
let token_vault_input = format!(
"{}-{:?}-{:?}",
vault_id,
alice.address(),
token_input.address()
);
let token_vault_output = format!(
"{}-{:?}-{:?}",
vault_id,
alice.address(),
token_output.address()
);

let token_vault_take_order_a_id = format!("{}-{}", take_order_entity, token_vault_input);
let token_vault_take_order_b_id = format!("{}-{}", take_order_entity, token_vault_output);
println!("take_order_entity: {}", take_order_entity);

let input_token = take_order_event
.config
Expand All @@ -2898,7 +2899,10 @@ async fn take_order_entity_take_order_test() -> anyhow::Result<()> {
let io_ratio =
divide_decimal_strings(&input_display, &output_display).unwrap_or("0".to_string());

let resp = Query::take_order_entity(&token_vault_input).await?;
// Wait for Subgraph sync
wait().await?;

let resp = Query::take_order_entity(&take_order_entity).await?;

assert_eq!(resp.sender, take_order_event.sender);
assert_eq!(resp.order, h256_to_bytes(&add_order_data.order_hash.into()));
Expand Down
2 changes: 1 addition & 1 deletion subgraph/tests/subgraph/wait/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub async fn wait() -> anyhow::Result<bool> {
return Err(anyhow!("wait function timeout"));
}
} else if deadline < current_time {
return Err(anyhow!("wait function timeout"));
return Err(anyhow!("wait function timeout in sync"));
}
} else {
println!("Errors : {:?}", response_body.errors.unwrap());
Expand Down

0 comments on commit e19b252

Please sign in to comment.