You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.1 KiB
43 lines
1.1 KiB
package lib
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/golang/mock/gomock"
|
|
"github.com/harmony-one/harmony/api/client"
|
|
proto_node "github.com/harmony-one/harmony/api/proto/node"
|
|
"github.com/harmony-one/harmony/core/types"
|
|
"github.com/harmony-one/harmony/node"
|
|
"github.com/harmony-one/harmony/p2p"
|
|
p2p_host "github.com/harmony-one/harmony/p2p/host"
|
|
mock_host "github.com/harmony-one/harmony/p2p/host/mock"
|
|
)
|
|
|
|
func TestCreateWalletNode(test *testing.T) {
|
|
walletNode := CreateWalletNode()
|
|
|
|
if walletNode.Client == nil {
|
|
test.Errorf("Wallet node's client is not initialized")
|
|
}
|
|
}
|
|
|
|
func TestSubmitTransaction(test *testing.T) {
|
|
ctrl := gomock.NewController(test)
|
|
defer ctrl.Finish()
|
|
|
|
m := mock_host.NewMockHost(ctrl)
|
|
|
|
m.EXPECT().GetSelfPeer().AnyTimes()
|
|
|
|
walletNode := node.New(m, nil, nil)
|
|
walletNode.Client = client.NewClient(walletNode.GetHost(), []uint32{0})
|
|
|
|
tx := &types.Transaction{}
|
|
msg := proto_node.ConstructTransactionListMessageAccount(types.Transactions{tx})
|
|
m.EXPECT().SendMessageToGroups([]p2p.GroupID{p2p.GroupIDBeaconClient}, p2p_host.ConstructP2pMessage(byte(0), msg))
|
|
|
|
SubmitTransaction(tx, walletNode, 0)
|
|
|
|
time.Sleep(1 * time.Second)
|
|
}
|
|
|