1- // Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
1+ // Copyright 2023-, Edge i Node, GraphOps, and Semiotic Labs.
22// SPDX-License-Identifier: Apache-2.0
33
44use anyhow:: Result ;
@@ -7,44 +7,22 @@ use serde_json::json;
77use std:: str:: FromStr ;
88use std:: sync:: Arc ;
99use std:: time:: Duration ;
10- use thegraph_core:: alloy:: signers:: local:: coins_bip39:: English ;
11- use thegraph_core:: alloy:: {
12- primitives:: Address ,
13- signers:: local:: { MnemonicBuilder , PrivateKeySigner } ,
14- } ;
10+ use thegraph_core:: alloy:: primitives:: Address ;
1511
16- use crate :: create_tap_receipt;
1712use crate :: MetricsChecker ;
1813
1914// TODO: Would be nice to read this values from:
2015// contrib/tap-agent/config.toml
2116// and contrib/local-network/.env
2217const GATEWAY_URL : & str = "http://localhost:7700" ;
2318const SUBGRAPH_ID : & str = "BFr2mx7FgkJ36Y6pE5BiXs1KmNUmVDCnL82KUSdcLW1g" ;
24- const TAP_ESCROW_CONTRACT : & str = "0x0355B7B8cb128fA5692729Ab3AAa199C1753f726" ;
2519const GATEWAY_API_KEY : & str = "deadbeefdeadbeefdeadbeefdeadbeef" ;
26- // const RECEIVER_ADDRESS: &str = "0xf4EF6650E48d099a4972ea5B414daB86e1998Bd3";
2720const TAP_AGENT_METRICS_URL : & str = "http://localhost:7300/metrics" ;
2821
29- const MNEMONIC : & str = "test test test test test test test test test test test junk" ;
3022const GRAPH_URL : & str = "http://localhost:8000/subgraphs/name/graph-network" ;
3123
32- const GRT_DECIMALS : u8 = 18 ;
33- const GRT_BASE : u128 = 10u128 . pow ( GRT_DECIMALS as u32 ) ;
34-
35- // With trigger_value_divisor = 500_000 and max_amount_willing_to_lose_grt = 1000
36- // trigger_value = 0.002 GRT
37- // We need to send at least 20 receipts to reach the trigger threshold
38- // Sending slightly more than required to ensure triggering
39- const MAX_RECEIPT_VALUE : u128 = GRT_BASE / 1_000 ;
40- // This value should match the timestamp_buffer_secs
41- // in the tap-agent setting + 10 seconds
4224const WAIT_TIME_BATCHES : u64 = 40 ;
4325
44- // Calculate required receipts to trigger RAV
45- // With MAX_RECEIPT_VALUE = GRT_BASE / 1_000 (0.001 GRT)
46- // And trigger_value = 0.002 GRT
47- // We need at least 3 receipts to trigger a RAV (0.003 GRT > 0.002 GRT)
4826const NUM_RECEIPTS : u32 = 3 ;
4927
5028// Send receipts in batches with a delay in between
@@ -54,15 +32,6 @@ const MAX_TRIGGERS: usize = 100;
5432
5533// Function to test the tap RAV generation
5634pub async fn test_tap_rav_v1 ( ) -> Result < ( ) > {
57- // Setup wallet using your MnemonicBuilder
58- let index: u32 = 0 ;
59- let wallet: PrivateKeySigner = MnemonicBuilder :: < English > :: default ( )
60- . phrase ( MNEMONIC )
61- . index ( index)
62- . unwrap ( )
63- . build ( )
64- . unwrap ( ) ;
65-
6635 // Setup HTTP client
6736 let http_client = Arc :: new ( Client :: new ( ) ) ;
6837
@@ -231,10 +200,6 @@ pub async fn test_tap_rav_v1() -> Result<()> {
231200
232201 println ! ( "\n === Summary ===" ) ;
233202 println ! ( "Total queries sent successfully: {}" , total_successful) ;
234- println ! (
235- "Total value sent: {} GRT" ,
236- ( MAX_RECEIPT_VALUE as f64 * total_successful as f64 ) / GRT_BASE as f64
237- ) ;
238203
239204 // If we got here, test failed
240205 println ! ( "❌ TEST FAILED: No RAV generation detected" ) ;
0 commit comments