@@ -22,14 +22,50 @@ use watch::{
2222} ;
2323
2424use log:: error;
25+ use std:: collections:: HashMap ;
2526use std:: env;
2627use std:: net:: SocketAddr ;
2728use std:: time:: Duration ;
2829use tokio:: { runtime, task:: JoinHandle } ;
2930use tokio_postgres:: { config:: Config as PostgresConfig , Client , NoTls } ;
3031use unused_port:: unused_tcp4_port;
3132
32- use testcontainers:: { clients:: Cli , images:: postgres:: Postgres , RunnableImage } ;
33+ use testcontainers:: { clients:: Cli , core:: WaitFor , Image , RunnableImage } ;
34+
35+ #[ derive( Debug ) ]
36+ pub struct Postgres ( HashMap < String , String > ) ;
37+
38+ impl Default for Postgres {
39+ fn default ( ) -> Self {
40+ let mut env_vars = HashMap :: new ( ) ;
41+ env_vars. insert ( "POSTGRES_DB" . to_owned ( ) , "postgres" . to_owned ( ) ) ;
42+ env_vars. insert ( "POSTGRES_HOST_AUTH_METHOD" . into ( ) , "trust" . into ( ) ) ;
43+
44+ Self ( env_vars)
45+ }
46+ }
47+
48+ impl Image for Postgres {
49+ type Args = ( ) ;
50+
51+ fn name ( & self ) -> String {
52+ "postgres" . to_owned ( )
53+ }
54+
55+ fn tag ( & self ) -> String {
56+ "11-alpine" . to_owned ( )
57+ }
58+
59+ fn ready_conditions ( & self ) -> Vec < WaitFor > {
60+ vec ! [ WaitFor :: message_on_stderr(
61+ "database system is ready to accept connections" ,
62+ ) ]
63+ }
64+
65+ fn env_vars ( & self ) -> Box < dyn Iterator < Item = ( & String , & String ) > + ' _ > {
66+ Box :: new ( self . 0 . iter ( ) )
67+ }
68+ }
3369
3470type E = MainnetEthSpec ;
3571
0 commit comments