2022-05-09 09:58:04 +02:00
|
|
|
package net
|
2022-05-08 13:13:45 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
2022-05-17 19:33:03 +02:00
|
|
|
|
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"
|
2022-05-08 13:13:45 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type tConfig struct {
|
|
|
|
rpcProvider string
|
|
|
|
tokenIndex string
|
|
|
|
privateKey string
|
|
|
|
}
|
|
|
|
|
|
|
|
var conf = &tConfig{
|
|
|
|
rpcProvider: os.Getenv("RPC_PROVIDER"),
|
|
|
|
tokenIndex: os.Getenv("TOKEN_INDEX"),
|
|
|
|
privateKey: os.Getenv("PRIVATE_KEY"),
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCicNet_Connect(t *testing.T) {
|
2022-05-18 11:52:50 +02:00
|
|
|
name := "Test CicNet connect"
|
2022-05-08 13:13:45 +02:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2022-05-18 12:41:55 +02:00
|
|
|
cicnet, _ := NewCicNet(newProvider, w3.A(conf.tokenIndex))
|
2022-05-08 13:13:45 +02:00
|
|
|
|
2022-05-09 09:58:04 +02:00
|
|
|
t.Run(name, func(t *testing.T) {
|
2022-05-18 11:52:50 +02:00
|
|
|
if err := cicnet.provider.EthClient.Close(); (err != nil) != wantErr {
|
2022-05-17 19:33:03 +02:00
|
|
|
t.Errorf("Error() error = %v, wantErr %v", err, wantErr)
|
2022-05-08 13:13:45 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|