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
6 years ago
|
package lib
|
||
6 years ago
|
|
||
|
import (
|
||
6 years ago
|
"testing"
|
||
|
"time"
|
||
|
|
||
6 years ago
|
"github.com/golang/mock/gomock"
|
||
|
"github.com/harmony-one/harmony/api/client"
|
||
|
"github.com/harmony-one/harmony/core/types"
|
||
6 years ago
|
"github.com/harmony-one/harmony/internal/utils"
|
||
6 years ago
|
"github.com/harmony-one/harmony/node"
|
||
|
"github.com/harmony-one/harmony/p2p"
|
||
|
mock_host "github.com/harmony-one/harmony/p2p/host/mock"
|
||
6 years ago
|
peer "github.com/libp2p/go-libp2p-peer"
|
||
6 years ago
|
)
|
||
|
|
||
|
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()
|
||
|
m.EXPECT().SendMessage(gomock.Any(), gomock.Any()).Times(1)
|
||
|
|
||
|
walletNode := node.New(m, nil, nil)
|
||
6 years ago
|
priKey, _, _ := utils.GenKeyP2P("127.0.0.1", "9990")
|
||
|
peerID, _ := peer.IDFromPrivateKey(priKey)
|
||
|
walletNode.Client = client.NewClient(walletNode.GetHost(), &map[uint32]p2p.Peer{0: p2p.Peer{IP: "127.0.0.1", Port: "9990", PeerID: peerID}})
|
||
6 years ago
|
|
||
|
SubmitTransaction(&types.Transaction{}, walletNode, 0)
|
||
|
|
||
|
time.Sleep(1 * time.Second)
|
||
|
}
|