File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
coprocessor/fhevm-engine/transaction-sender/tests Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ pub struct TestEnvironment {
5454 anvil : Option < AnvilInstance > ,
5555 pub wallet : EthereumWallet ,
5656 _db_instance : DBInstance ,
57+ // Just keep the handle to destroy the container when it is dropped.
5758 _localstack : Option < LocalstackContainer > ,
5859}
5960
@@ -88,6 +89,20 @@ impl TestEnvironment {
8889 . connect ( db_instance. db_url ( ) )
8990 . await ?;
9091
92+ Self :: truncate_tables (
93+ & db_pool,
94+ vec ! [
95+ "verify_proofs" ,
96+ "ciphertext_digest" ,
97+ "allowed_handles" ,
98+ "delegate_user_decrypt" ,
99+ "keys" ,
100+ "crs" ,
101+ "host_chains" ,
102+ ] ,
103+ )
104+ . await ?;
105+
91106 let anvil = Self :: new_anvil ( ) ?;
92107 let chain_id =
93108 get_chain_id ( anvil. ws_endpoint_url ( ) , std:: time:: Duration :: from_secs ( 1 ) ) . await ;
@@ -167,4 +182,12 @@ impl TestEnvironment {
167182 fn new_anvil_with_port ( port : u16 ) -> anyhow:: Result < AnvilInstance > {
168183 Ok ( Anvil :: new ( ) . block_time ( 1 ) . port ( port) . try_spawn ( ) ?)
169184 }
185+
186+ async fn truncate_tables ( db_pool : & sqlx:: PgPool , tables : Vec < & str > ) -> Result < ( ) , sqlx:: Error > {
187+ for table in tables {
188+ let query = format ! ( "TRUNCATE {}" , table) ;
189+ sqlx:: query ( & query) . execute ( db_pool) . await ?;
190+ }
191+ Ok ( ( ) )
192+ }
170193}
You can’t perform that action at this time.
0 commit comments