2022-05-17 19:33:03 +02:00
|
|
|
package balance
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
2022-05-18 11:52:50 +02:00
|
|
|
"github.com/grassrootseconomics/cic-go/provider"
|
2022-05-17 19:33:03 +02:00
|
|
|
"github.com/lmittmann/w3"
|
|
|
|
)
|
|
|
|
|
|
|
|
type tConfig struct {
|
|
|
|
rpcProvider string
|
|
|
|
batchContract string
|
|
|
|
}
|
|
|
|
|
|
|
|
var conf = &tConfig{
|
|
|
|
rpcProvider: os.Getenv("RPC_PROVIDER"),
|
|
|
|
batchContract: os.Getenv("BATCH_CONTRACT"),
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBatchBalance_Connect(t *testing.T) {
|
|
|
|
name := "Test RPC connection"
|
|
|
|
wantErr := false
|
|
|
|
|
2022-05-18 11:52:50 +02:00
|
|
|
newProvider, err := provider.NewRpcProvider(conf.rpcProvider)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Creating an rpc instance failed = %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
batchBalance, _ := NewBatchBalance(*newProvider, w3.A(conf.batchContract))
|
2022-05-17 19:33:03 +02:00
|
|
|
|
|
|
|
t.Run(name, func(t *testing.T) {
|
2022-05-18 11:52:50 +02:00
|
|
|
if err := batchBalance.provider.EthClient.Close(); (err != nil) != wantErr {
|
2022-05-17 19:33:03 +02:00
|
|
|
t.Errorf("Close() error = %v, wantErr %v", err, wantErr)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|