Last active
December 19, 2018 09:11
-
-
Save natemurthy/f17bd5b553989cfcddc06babd9cf541f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"math/big" | |
"testing" | |
"github.com/ethereum/go-ethereum/accounts/abi/bind" | |
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends" | |
"github.com/ethereum/go-ethereum/common" | |
"github.com/ethereum/go-ethereum/core" | |
"github.com/ethereum/go-ethereum/crypto" | |
"github.com/stretchr/testify/suite" | |
) | |
type HelloworldTestSuite struct { | |
suite.Suite | |
auth *bind.TransactOpts | |
address common.Address | |
gAlloc core.GenesisAlloc | |
sim *backends.SimulatedBackend | |
helloworld *Helloworld | |
} | |
func TestRunHelloworldSuite(t *testing.T) { | |
suite.Run(t, new(HelloworldTestSuite)) | |
} | |
func (s *HelloworldTestSuite) SetupTest() { | |
key, _ := crypto.GenerateKey() | |
s.auth = bind.NewKeyedTransactor(key) | |
s.address = s.auth.From | |
s.gAlloc = map[common.Address]core.GenesisAccount{ | |
s.address: {Balance: big.NewInt(10000000000)}, | |
} | |
s.sim = backends.NewSimulatedBackend(s.gAlloc) | |
_, _, hw, e := DeployHelloworld(s.auth, s.sim) | |
s.helloworld = hw | |
s.Nil(e) | |
s.sim.Commit() | |
} | |
func (s *HelloworldTestSuite) TestSay() { | |
str, err := s.helloworld.Say(nil) | |
s.Equal("hello etherworld", str) | |
s.Nil(err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment