File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
framework/components/blockchain Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ package blockchain
22
33import (
44 "fmt"
5+ "testing"
6+
57 "github.com/testcontainers/testcontainers-go"
68)
79
@@ -26,6 +28,9 @@ type Input struct {
2628 // a map of program name to program id
2729 // there needs to be a matching .so file in contracts_dir
2830 SolanaPrograms map [string ]string `toml:"solana_programs"`
31+
32+ // used to cancel container contexts
33+ T * testing.T `toml:"testing"`
2934}
3035
3136// Output is a blockchain network output, ChainID and one or more nodes that forms the network
Original file line number Diff line number Diff line change @@ -131,6 +131,13 @@ func newSolana(in *Input) (*Output, error) {
131131 ContainerRequest : req ,
132132 Started : true ,
133133 })
134+ // Call cleanup container indiscriminately
135+ // This should be called as a defer directly after (before any error check)
136+ // of [GenericContainer](...) or a modules Run(...) in a test to ensure the
137+ // container is stopped when the function ends.
138+ if in .T != nil {
139+ testcontainers .CleanupContainer (in .T , c )
140+ }
134141 if err != nil {
135142 return nil , err
136143 }
You can’t perform that action at this time.
0 commit comments