diff --git a/cmd/serve.go b/cmd/serve.go index 61fdda0e4b85ea3aa2f8a55fccc4674fb5a86d6c..6d3f82d556b53a9d463c157bc9eb0063c9f4c453 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -143,6 +143,7 @@ func Serve(cmd *cobra.Command, args []string) { log.Fatalf("Failed to load server configuration: %s.", err) os.Exit(1) } + serverProcess, err := newCore.NewGatewayV0(serverConfig) if err != nil { log.Fatalf("Failed to load servers: %s.", err) diff --git a/definitions/pipe.go b/definitions/pipe.go index 0a045442a3fac19e655fad1e8aaf92fc24ed9d69..285f8b53fccac575cd034b8742d8fcb83c9a18c2 100644 --- a/definitions/pipe.go +++ b/definitions/pipe.go @@ -38,7 +38,6 @@ import ( type Pipe interface { Accounts() Accounts Blockchain() blockchain_types.Blockchain - Consensus() consensus_types.ConsensusEngine Events() event.EventEmitter NameReg() NameReg Net() Net @@ -91,6 +90,5 @@ type Transactor interface { fee int64) (*txs.EventDataCall, error) TransactNameReg(privKey []byte, name, data string, amount, fee int64) (*txs.Receipt, error) - UnconfirmedTxs() (*txs.UnconfirmedTxs, error) SignTx(tx txs.Tx, privAccounts []*account.PrivAccount) (txs.Tx, error) } diff --git a/manager/eris-mint/pipe.go b/manager/eris-mint/pipe.go index b05ad45e737fbcafa20648029358d97dbb04509c..b806b8c8983915fa86554e9b19139cefb8d296b6 100644 --- a/manager/eris-mint/pipe.go +++ b/manager/eris-mint/pipe.go @@ -181,10 +181,6 @@ func (pipe *erisMintPipe) Blockchain() blockchain_types.Blockchain { return pipe.blockchain } -func (pipe *erisMintPipe) Consensus() consensus_types.ConsensusEngine { - return pipe.consensusEngine -} - func (pipe *erisMintPipe) Events() edb_event.EventEmitter { return pipe.events } @@ -395,7 +391,7 @@ func (pipe *erisMintPipe) DumpStorage(address []byte) (*rpc_tm_types.ResultDumpS return &rpc_tm_types.ResultDumpStorage{storageRoot, storageItems}, nil } -// Call +// Call // NOTE: this function is used from 46657 and has sibling on 1337 // in transactor.go // TODO: [ben] resolve incompatibilities in byte representation for 0.12.0 release @@ -638,15 +634,15 @@ func (pipe *erisMintPipe) ListValidators() (*rpc_tm_types.ResultListValidators, // TODO: when we reintroduce support for bonding and unbonding update this // to reflect the mutable bonding state return &rpc_tm_types.ResultListValidators{ - BlockHeight: consensusState.Height, - BondedValidators: validators, + BlockHeight: consensusState.Height, + BondedValidators: validators, UnbondingValidators: nil, }, nil } func (pipe *erisMintPipe) DumpConsensusState() (*rpc_tm_types.ResultDumpConsensusState, error) { return &rpc_tm_types.ResultDumpConsensusState{ - ConsensusState: pipe.consensusEngine.ConsensusState(), + ConsensusState: pipe.consensusEngine.ConsensusState(), PeerConsensusStates: pipe.consensusEngine.PeerConsensusStates(), }, nil } diff --git a/manager/eris-mint/transactor.go b/manager/eris-mint/transactor.go index 71c342a85f47a4e6216f3a44b9d898755648b270..3b971d3702d72040d7132b7aba7f24d913686be7 100644 --- a/manager/eris-mint/transactor.go +++ b/manager/eris-mint/transactor.go @@ -151,12 +151,6 @@ func (this *transactor) BroadcastTx(tx txs.Tx) (*txs.Receipt, error) { return &txs.Receipt{txHash, createsContract, contractAddr}, nil } -// Get all unconfirmed txs. -func (this *transactor) UnconfirmedTxs() (*txs.UnconfirmedTxs, error) { - // TODO-RPC - return &txs.UnconfirmedTxs{}, nil -} - // Orders calls to BroadcastTx using lock (waits for response from core before releasing) func (this *transactor) Transact(privKey, address, data []byte, gasLimit, fee int64) (*txs.Receipt, error) { diff --git a/rpc/tendermint/client/client.go b/rpc/tendermint/client/client.go index 6be71caa662d34786d9e0ec7841e6652ca7f8725..53869372ce75d5b0242094887f470ad5d7fd11a6 100644 --- a/rpc/tendermint/client/client.go +++ b/rpc/tendermint/client/client.go @@ -126,6 +126,14 @@ func BlockchainInfo(client rpcclient.Client, minHeight, return res.(*rpc_types.ResultBlockchainInfo), err } +func ListUnconfirmedTxs(client rpcclient.Client) (*rpc_types.ResultListUnconfirmedTxs, error) { + res, err := performCall(client, "list_unconfirmed_txs") + if err != nil { + return nil, err + } + return res.(*rpc_types.ResultListUnconfirmedTxs), err +} + func performCall(client rpcclient.Client, method string, paramKeyVals ...interface{}) (res rpc_types.ErisDBResult, err error) { paramsMap, paramsSlice, err := mapAndValues(paramKeyVals...) diff --git a/rpc/tendermint/core/routes.go b/rpc/tendermint/core/routes.go index 8696ba8388d3d336fe5f71aaa2831d19f8d7eef2..4d215aa85f74cc166e853215511642d66ff0d1cf 100644 --- a/rpc/tendermint/core/routes.go +++ b/rpc/tendermint/core/routes.go @@ -213,7 +213,7 @@ func (tmRoutes *TendermintRoutes) BlockchainInfo(minHeight, func (tmRoutes *TendermintRoutes) ListUnconfirmedTxs() (ctypes.ErisDBResult, error) { // Get all Txs for now - r, err := tmRoutes.tendermintPipe.ListUnconfirmedTxs(0) + r, err := tmRoutes.tendermintPipe.ListUnconfirmedTxs(-1) if err != nil { return nil, err } else { diff --git a/rpc/tendermint/test/rpc_client_test.go b/rpc/tendermint/test/rpc_client_test.go index 6c3b5887cd5e535bdd70520c3ecd637f6784f5f6..2e25c02f04be718dc249f8c71c95451f6c67cfc4 100644 --- a/rpc/tendermint/test/rpc_client_test.go +++ b/rpc/tendermint/test/rpc_client_test.go @@ -10,6 +10,8 @@ import ( "golang.org/x/crypto/ripemd160" + "time" + edbcli "github.com/eris-ltd/eris-db/rpc/tendermint/client" "github.com/eris-ltd/eris-db/txs" "github.com/stretchr/testify/assert" @@ -27,7 +29,6 @@ import ( func testWithAllClients(t *testing.T, testFunction func(*testing.T, string, rpcclient.Client)) { for clientName, client := range clients { - fmt.Printf("\x1b[47m\x1b[31mMARMOT DEBUG: Loop \x1b[0m\n") testFunction(t, clientName, client) } } @@ -55,7 +56,7 @@ func TestBroadcastTx(t *testing.T) { toAddr := user[1].Address tx := makeDefaultSendTxSigned(t, client, toAddr, amt) //receipt := broadcastTx(t, client, tx) - receipt, err := broadcastTxAndWaitForBlock(t, client,wsc, tx) + receipt, err := broadcastTxAndWaitForBlock(t, client, wsc, tx) if err != nil { t.Fatal(err) } @@ -93,7 +94,8 @@ func TestGetAccount(t *testing.T) { t.Fatal("Account was nil") } if bytes.Compare(acc.Address, user[0].Address) != 0 { - t.Fatalf("Failed to get correct account. Got %x, expected %x", acc.Address, user[0].Address) + t.Fatalf("Failed to get correct account. Got %x, expected %x", acc.Address, + user[0].Address) } }) } @@ -318,6 +320,46 @@ func TestListUnconfirmedTxs(t *testing.T) { if testing.Short() { t.Skip("skipping test in short mode.") } + wsc := newWSClient(t) + testWithAllClients(t, func(t *testing.T, clientName string, client rpcclient.Client) { + amt, gasLim, fee := int64(1100), int64(1000), int64(1000) + code := []byte{0x60, 0x5, 0x60, 0x1, 0x55} + // Call with nil address will create a contract + tx := makeDefaultCallTx(t, client, []byte{}, code, amt, gasLim, fee) + + txChan := make(chan []txs.Tx) + go func() { + for { + resp, err := edbcli.ListUnconfirmedTxs(client) + if err != nil { + t.Fatal(err) + } + if resp.N > 0 { + txChan <- resp.Txs + } + } + }() + + // We want to catch the Tx in mempool before it gets reaped by tendermint + // consensus. We should be able to do this almost always if we broadcast our + // transaction immediately after a block has been committed. There is about + // 1 second between blocks, and we will have the lock on Reap + // So we wait for a block here + waitNBlocks(t, wsc, 1) + runThenWaitForBlock(t, wsc, nextBlockPredicateFn(), func() { + broadcastTx(t, client, tx) + select { + case <-time.After(time.Second * timeoutSeconds): + t.Fatal("Timeout out waiting for unconfirmed transactions to appear") + case transactions := <-txChan: + assert.Len(t, transactions, 1, + "There should only be a single transaction in the mempool during "+ + "this test (previous txs should have made it into a block)") + assert.Contains(t, transactions, tx, + "Transaction should be returned by ListUnconfirmedTxs") + } + }) + }) } func asEventDataTx(t *testing.T, eventData txs.EventData) txs.EventDataTx { diff --git a/rpc/tendermint/test/websocket_helpers.go b/rpc/tendermint/test/websocket_helpers.go index ef34569c31c100fdd4ba9712fef7d86ab7d7286b..b135fa1d6200c8e8d4c58d3d24ebce8f3613402d 100644 --- a/rpc/tendermint/test/websocket_helpers.go +++ b/rpc/tendermint/test/websocket_helpers.go @@ -21,6 +21,7 @@ const ( //-------------------------------------------------------------------------------- // Utilities for testing the websocket service +type blockPredicate func(block *tm_types.Block) bool // create a new connection func newWSClient(t *testing.T) *rpcclient.WSClient { @@ -70,21 +71,7 @@ func broadcastTxAndWaitForBlock(t *testing.T, client rpcclient.Client, wsc *rpcc tx txs.Tx) (txs.Receipt, error) { var rec txs.Receipt var err error - initialHeight := -1 - runThenWaitForBlock(t, wsc, - func(block *tm_types.Block) bool { - if initialHeight < 0 { - initialHeight = block.Height - return false - } else { - // TODO: [Silas] remove the + 1 here. It is a workaround for the fact - // that tendermint fires the NewBlock event before it has finalised its - // state updates, so we have to wait for the block after the block we - // want in order for the Tx to be genuinely final. - // This should be addressed by: https://github.com/tendermint/tendermint/pull/265 - return block.Height > initialHeight+1 - } - }, + runThenWaitForBlock(t, wsc, nextBlockPredicateFn(), func() { rec, err = edbcli.BroadcastTx(client, tx) mempoolCount += 1 @@ -92,6 +79,23 @@ func broadcastTxAndWaitForBlock(t *testing.T, client rpcclient.Client, wsc *rpcc return rec, err } +func nextBlockPredicateFn() blockPredicate { + initialHeight := -1 + return func(block *tm_types.Block) bool { + if initialHeight <= 0 { + initialHeight = block.Height + return false + } else { + // TODO: [Silas] remove the + 1 here. It is a workaround for the fact + // that tendermint fires the NewBlock event before it has finalised its + // state updates, so we have to wait for the block after the block we + // want in order for the Tx to be genuinely final. + // This should be addressed by: https://github.com/tendermint/tendermint/pull/265 + return block.Height > initialHeight+1 + } + } +} + func waitNBlocks(t *testing.T, wsc *rpcclient.WSClient, n int) { i := 0 runThenWaitForBlock(t, wsc, @@ -103,11 +107,11 @@ func waitNBlocks(t *testing.T, wsc *rpcclient.WSClient, n int) { } func runThenWaitForBlock(t *testing.T, wsc *rpcclient.WSClient, - blockPredicate func(*tm_types.Block) bool, runner func()) { + predicate blockPredicate, runner func()) { subscribeAndWaitForNext(t, wsc, txs.EventStringNewBlock(), runner, func(event string, eventData txs.EventData) (bool, error) { - return blockPredicate(eventData.(txs.EventDataNewBlock).Block), nil + return predicate(eventData.(txs.EventDataNewBlock).Block), nil }) } diff --git a/rpc/v0/methods.go b/rpc/v0/methods.go index 8e888e6b3dd69d026c4c2c5e638e06e05c16220a..a7bcf609ad334f1a6e160e752d1da35a3b28f247 100644 --- a/rpc/v0/methods.go +++ b/rpc/v0/methods.go @@ -256,11 +256,11 @@ func (erisDbMethods *ErisDbMethods) Block(request *rpc.RPCRequest, requester int // *************************************** Consensus ************************************ func (erisDbMethods *ErisDbMethods) ConsensusState(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { - return erisDbMethods.pipe.Consensus().ConsensusState(), 0, nil + return erisDbMethods.pipe.GetConsensusEngine().ConsensusState(), 0, nil } func (erisDbMethods *ErisDbMethods) Validators(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { - return erisDbMethods.pipe.Consensus().ListValidators(), 0, nil + return erisDbMethods.pipe.GetConsensusEngine().ListValidators(), 0, nil } // *************************************** Net ************************************ @@ -414,11 +414,11 @@ func (erisDbMethods *ErisDbMethods) TransactNameReg(request *rpc.RPCRequest, req } func (erisDbMethods *ErisDbMethods) UnconfirmedTxs(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { - txs, errC := erisDbMethods.pipe.Transactor().UnconfirmedTxs() + trans, errC := erisDbMethods.pipe.GetConsensusEngine().ListUnconfirmedTxs(-1) if errC != nil { return nil, rpc.INTERNAL_ERROR, errC } - return txs, 0, nil + return txs.UnconfirmedTxs{trans}, 0, nil } func (erisDbMethods *ErisDbMethods) SignTx(request *rpc.RPCRequest, requester interface{}) (interface{}, int, error) { diff --git a/rpc/v0/restServer.go b/rpc/v0/restServer.go index 42c925a3634e349bcdbd81f855ecd3c51b0fd381..2c94bdfe708e1b30cd67be181c07879d5b57d574 100644 --- a/rpc/v0/restServer.go +++ b/rpc/v0/restServer.go @@ -221,13 +221,13 @@ func (restServer *RestServer) handleBlock(c *gin.Context) { // ********************************* Consensus ********************************* func (restServer *RestServer) handleConsensusState(c *gin.Context) { - cs := restServer.pipe.Consensus().ConsensusState() + cs := restServer.pipe.GetConsensusEngine().ConsensusState() c.Writer.WriteHeader(200) restServer.codec.Encode(cs, c.Writer) } func (restServer *RestServer) handleValidatorList(c *gin.Context) { - vl := restServer.pipe.Consensus().ListValidators() + vl := restServer.pipe.GetConsensusEngine().ListValidators() c.Writer.WriteHeader(200) restServer.codec.Encode(vl, c.Writer) } @@ -377,13 +377,12 @@ func (restServer *RestServer) handleBroadcastTx(c *gin.Context) { } func (restServer *RestServer) handleUnconfirmedTxs(c *gin.Context) { - - txs, err := restServer.pipe.Transactor().UnconfirmedTxs() + trans, err := restServer.pipe.GetConsensusEngine().ListUnconfirmedTxs(-1) if err != nil { c.AbortWithError(500, err) } c.Writer.WriteHeader(200) - restServer.codec.Encode(txs, c.Writer) + restServer.codec.Encode(txs.UnconfirmedTxs{trans}, c.Writer) } func (restServer *RestServer) handleCall(c *gin.Context) { diff --git a/test/mock/pipe.go b/test/mock/pipe.go index b8394ad9ad9e73db7cd0aa46d04bf86f40456f40..d57f781e7c6a6965e07f21846f2e1663b0c8ba70 100644 --- a/test/mock/pipe.go +++ b/test/mock/pipe.go @@ -39,7 +39,7 @@ func NewMockPipe(td *td.TestData) definitions.Pipe { consensusEngine := &consensusEngine{td} eventer := &eventer{td} namereg := &namereg{td} - net := &net{td} + net := &network{td} transactor := &transactor{td} return &MockPipe{ td, @@ -58,63 +58,59 @@ func NewDefaultMockPipe() definitions.Pipe { return NewMockPipe(td.LoadTestData()) } -func (this *MockPipe) Accounts() definitions.Accounts { - return this.accounts +func (pipe *MockPipe) Accounts() definitions.Accounts { + return pipe.accounts } -func (this *MockPipe) Blockchain() blockchain_types.Blockchain { - return this.blockchain +func (pipe *MockPipe) Blockchain() blockchain_types.Blockchain { + return pipe.blockchain } -func (this *MockPipe) Consensus() consensus_types.ConsensusEngine { - return this.consensusEngine +func (pipe *MockPipe) Events() event.EventEmitter { + return pipe.events } -func (this *MockPipe) Events() event.EventEmitter { - return this.events +func (pipe *MockPipe) NameReg() definitions.NameReg { + return pipe.namereg } -func (this *MockPipe) NameReg() definitions.NameReg { - return this.namereg +func (pipe *MockPipe) Net() definitions.Net { + return pipe.net } -func (this *MockPipe) Net() definitions.Net { - return this.net +func (pipe *MockPipe) Transactor() definitions.Transactor { + return pipe.transactor } -func (this *MockPipe) Transactor() definitions.Transactor { - return this.transactor -} - -func (this *MockPipe) GetApplication() manager_types.Application { +func (pipe *MockPipe) GetApplication() manager_types.Application { // TODO: [ben] mock application return nil } -func (this *MockPipe) SetConsensusEngine(_ consensus_types.ConsensusEngine) error { +func (pipe *MockPipe) SetConsensusEngine(_ consensus_types.ConsensusEngine) error { // TODO: [ben] mock consensus engine return nil } -func (this *MockPipe) GetConsensusEngine() consensus_types.ConsensusEngine { - return nil +func (pipe *MockPipe) GetConsensusEngine() consensus_types.ConsensusEngine { + return pipe.consensusEngine } -func (this *MockPipe) SetBlockchain(_ blockchain_types.Blockchain) error { +func (pipe *MockPipe) SetBlockchain(_ blockchain_types.Blockchain) error { // TODO: [ben] mock consensus engine return nil } -func (this *MockPipe) GetBlockchain() blockchain_types.Blockchain { +func (pipe *MockPipe) GetBlockchain() blockchain_types.Blockchain { return nil } -func (this *MockPipe) GetTendermintPipe() (definitions.TendermintPipe, error) { +func (pipe *MockPipe) GetTendermintPipe() (definitions.TendermintPipe, error) { return nil, fmt.Errorf("Tendermint pipe is not supported by mocked pipe.") } -func (this *MockPipe) GenesisHash() []byte { - return this.testData.GetGenesisHash.Output.Hash +func (pipe *MockPipe) GenesisHash() []byte { + return pipe.testData.GetGenesisHash.Output.Hash } // Components @@ -124,28 +120,28 @@ type accounts struct { testData *td.TestData } -func (this *accounts) GenPrivAccount() (*account.PrivAccount, error) { - return this.testData.GenPrivAccount.Output, nil +func (acc *accounts) GenPrivAccount() (*account.PrivAccount, error) { + return acc.testData.GenPrivAccount.Output, nil } -func (this *accounts) GenPrivAccountFromKey(key []byte) (*account.PrivAccount, error) { - return this.testData.GenPrivAccount.Output, nil +func (acc *accounts) GenPrivAccountFromKey(key []byte) (*account.PrivAccount, error) { + return acc.testData.GenPrivAccount.Output, nil } -func (this *accounts) Accounts([]*event.FilterData) (*core_types.AccountList, error) { - return this.testData.GetAccounts.Output, nil +func (acc *accounts) Accounts([]*event.FilterData) (*core_types.AccountList, error) { + return acc.testData.GetAccounts.Output, nil } -func (this *accounts) Account(address []byte) (*account.Account, error) { - return this.testData.GetAccount.Output, nil +func (acc *accounts) Account(address []byte) (*account.Account, error) { + return acc.testData.GetAccount.Output, nil } -func (this *accounts) Storage(address []byte) (*core_types.Storage, error) { - return this.testData.GetStorage.Output, nil +func (acc *accounts) Storage(address []byte) (*core_types.Storage, error) { + return acc.testData.GetStorage.Output, nil } -func (this *accounts) StorageAt(address, key []byte) (*core_types.StorageItem, error) { - return this.testData.GetStorageAt.Output, nil +func (acc *accounts) StorageAt(address, key []byte) (*core_types.StorageItem, error) { + return acc.testData.GetStorageAt.Output, nil } // Blockchain @@ -209,8 +205,7 @@ func (cons *consensusEngine) Events() event.EventEmitter { } func (cons *consensusEngine) ListUnconfirmedTxs(maxTxs int) ([]txs.Tx, error) { - return nil, nil - + return cons.testData.GetUnconfirmedTxs.Output.Txs, nil } func (cons *consensusEngine) ListValidators() []consensus_types.Validator { @@ -230,11 +225,11 @@ type eventer struct { testData *td.TestData } -func (this *eventer) Subscribe(subId, event string, callback func(txs.EventData)) error { +func (evntr *eventer) Subscribe(subId, event string, callback func(txs.EventData)) error { return nil } -func (this *eventer) Unsubscribe(subId string) error { +func (evntr *eventer) Unsubscribe(subId string) error { return nil } @@ -243,45 +238,45 @@ type namereg struct { testData *td.TestData } -func (this *namereg) Entry(key string) (*core_types.NameRegEntry, error) { - return this.testData.GetNameRegEntry.Output, nil +func (nmreg *namereg) Entry(key string) (*core_types.NameRegEntry, error) { + return nmreg.testData.GetNameRegEntry.Output, nil } -func (this *namereg) Entries(filters []*event.FilterData) (*core_types.ResultListNames, error) { - return this.testData.GetNameRegEntries.Output, nil +func (nmreg *namereg) Entries(filters []*event.FilterData) (*core_types.ResultListNames, error) { + return nmreg.testData.GetNameRegEntries.Output, nil } // Net -type net struct { +type network struct { testData *td.TestData } -func (this *net) Info() (*core_types.NetworkInfo, error) { - return this.testData.GetNetworkInfo.Output, nil +func (net *network) Info() (*core_types.NetworkInfo, error) { + return net.testData.GetNetworkInfo.Output, nil } -func (this *net) ClientVersion() (string, error) { - return this.testData.GetClientVersion.Output.ClientVersion, nil +func (net *network) ClientVersion() (string, error) { + return net.testData.GetClientVersion.Output.ClientVersion, nil } -func (this *net) Moniker() (string, error) { - return this.testData.GetMoniker.Output.Moniker, nil +func (net *network) Moniker() (string, error) { + return net.testData.GetMoniker.Output.Moniker, nil } -func (this *net) Listening() (bool, error) { - return this.testData.IsListening.Output.Listening, nil +func (net *network) Listening() (bool, error) { + return net.testData.IsListening.Output.Listening, nil } -func (this *net) Listeners() ([]string, error) { - return this.testData.GetListeners.Output.Listeners, nil +func (net *network) Listeners() ([]string, error) { + return net.testData.GetListeners.Output.Listeners, nil } -func (this *net) Peers() ([]*core_types.Peer, error) { - return this.testData.GetPeers.Output, nil +func (net *network) Peers() ([]*core_types.Peer, error) { + return net.testData.GetPeers.Output, nil } -func (this *net) Peer(address string) (*core_types.Peer, error) { - // return this.testData.GetPeer.Output, nil +func (net *network) Peer(address string) (*core_types.Peer, error) { + // return net.testData.GetPeer.Output, nil return nil, nil } @@ -290,45 +285,41 @@ type transactor struct { testData *td.TestData } -func (this *transactor) Call(fromAddress, toAddress, data []byte) (*core_types.Call, error) { - return this.testData.Call.Output, nil +func (trans *transactor) Call(fromAddress, toAddress, data []byte) (*core_types.Call, error) { + return trans.testData.Call.Output, nil } -func (this *transactor) CallCode(from, code, data []byte) (*core_types.Call, error) { - return this.testData.CallCode.Output, nil +func (trans *transactor) CallCode(from, code, data []byte) (*core_types.Call, error) { + return trans.testData.CallCode.Output, nil } -func (this *transactor) BroadcastTx(tx txs.Tx) (*txs.Receipt, error) { +func (trans *transactor) BroadcastTx(tx txs.Tx) (*txs.Receipt, error) { return nil, nil } -func (this *transactor) UnconfirmedTxs() (*txs.UnconfirmedTxs, error) { - return this.testData.GetUnconfirmedTxs.Output, nil -} - -func (this *transactor) Transact(privKey, address, data []byte, gasLimit, fee int64) (*txs.Receipt, error) { +func (trans *transactor) Transact(privKey, address, data []byte, gasLimit, fee int64) (*txs.Receipt, error) { if address == nil || len(address) == 0 { - return this.testData.TransactCreate.Output, nil + return trans.testData.TransactCreate.Output, nil } - return this.testData.Transact.Output, nil + return trans.testData.Transact.Output, nil } -func (this *transactor) TransactAndHold(privKey, address, data []byte, gasLimit, fee int64) (*txs.EventDataCall, error) { +func (trans *transactor) TransactAndHold(privKey, address, data []byte, gasLimit, fee int64) (*txs.EventDataCall, error) { return nil, nil } -func (this *transactor) Send(privKey, toAddress []byte, amount int64) (*txs.Receipt, error) { +func (trans *transactor) Send(privKey, toAddress []byte, amount int64) (*txs.Receipt, error) { return nil, nil } -func (this *transactor) SendAndHold(privKey, toAddress []byte, amount int64) (*txs.Receipt, error) { +func (trans *transactor) SendAndHold(privKey, toAddress []byte, amount int64) (*txs.Receipt, error) { return nil, nil } -func (this *transactor) TransactNameReg(privKey []byte, name, data string, amount, fee int64) (*txs.Receipt, error) { - return this.testData.TransactNameReg.Output, nil +func (trans *transactor) TransactNameReg(privKey []byte, name, data string, amount, fee int64) (*txs.Receipt, error) { + return trans.testData.TransactNameReg.Output, nil } -func (this *transactor) SignTx(tx txs.Tx, privAccounts []*account.PrivAccount) (txs.Tx, error) { +func (trans *transactor) SignTx(tx txs.Tx, privAccounts []*account.PrivAccount) (txs.Tx, error) { return nil, nil } diff --git a/txs/tx.go b/txs/tx.go index e0069c5b78af512b225075696bd5e089e2c2b71b..a216332031d24951fdc63d1f12a57b9f8f932fc7 100644 --- a/txs/tx.go +++ b/txs/tx.go @@ -340,7 +340,7 @@ func (tx *RebondTx) String() string { //----------------------------------------------------------------------------- type DupeoutTx struct { - Address []byte `json:"address"` + Address []byte `json:"address"` VoteA tendermint_types.Vote `json:"vote_a"` VoteB tendermint_types.Vote `json:"vote_b"` } diff --git a/txs/tx_test.go b/txs/tx_test.go index 1fecefa56aa3cde6bfff8e45e6f10271de91b2f6..e3f092da5679bd78f2b0ff1e1a4423f8eb960565 100644 --- a/txs/tx_test.go +++ b/txs/tx_test.go @@ -181,7 +181,7 @@ func TestEncodeTxDecodeTx(t *testing.T) { inputAddress := []byte{1, 2, 3, 4, 5} outputAddress := []byte{5, 4, 3, 2, 1} amount := int64(2) - sequence := 1 + sequence := 3 tx := &SendTx{ Inputs: []*TxInput{{ Address: inputAddress,