diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-10-19 18:29:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-19 18:29:46 +0800 |
commit | bec97aadfa95ebb42ef042bd53c7976ae410c496 (patch) | |
tree | 033a4e492819bcd027c7487c9b4f43bb6f93be79 /simulation | |
parent | d42b96124b8d1d43828b4c36b158408ff17aea69 (diff) | |
download | dexon-consensus-bec97aadfa95ebb42ef042bd53c7976ae410c496.tar dexon-consensus-bec97aadfa95ebb42ef042bd53c7976ae410c496.tar.gz dexon-consensus-bec97aadfa95ebb42ef042bd53c7976ae410c496.tar.bz2 dexon-consensus-bec97aadfa95ebb42ef042bd53c7976ae410c496.tar.lz dexon-consensus-bec97aadfa95ebb42ef042bd53c7976ae410c496.tar.xz dexon-consensus-bec97aadfa95ebb42ef042bd53c7976ae410c496.tar.zst dexon-consensus-bec97aadfa95ebb42ef042bd53c7976ae410c496.zip |
misc: Fix simulation error (#230)
Diffstat (limited to 'simulation')
-rw-r--r-- | simulation/app.go | 7 | ||||
-rw-r--r-- | simulation/app_test.go | 43 | ||||
-rw-r--r-- | simulation/node.go | 2 |
3 files changed, 48 insertions, 4 deletions
diff --git a/simulation/app.go b/simulation/app.go index 16bb63a..f8bbcc6 100644 --- a/simulation/app.go +++ b/simulation/app.go @@ -61,9 +61,9 @@ func newSimApp(id types.NodeID, netModule *network) *simApp { func (a *simApp) BlockConfirmed(block types.Block) { a.blockByHashMutex.Lock() defer a.blockByHashMutex.Unlock() - // TODO(jimmy-dexon) : Remove block in this hash if it's no longer needed. a.blockByHash[block.Hash] = &block + a.blockSeen[block.Hash] = time.Now().UTC() } // VerifyBlock implements core.Application. @@ -119,8 +119,9 @@ func (a *simApp) StronglyAcked(blockHash common.Hash) { // TotalOrderingDelivered is called when blocks are delivered by the total // ordering algorithm. -func (a *simApp) TotalOrderingDelivered(blockHashes common.Hashes, early bool) { - fmt.Println("OUTPUT", a.NodeID, early, blockHashes) +func (a *simApp) TotalOrderingDelivered( + blockHashes common.Hashes, mode uint32) { + fmt.Println("OUTPUT", a.NodeID, mode, blockHashes) blockList := &BlockList{ ID: a.DeliverID, BlockHash: blockHashes, diff --git a/simulation/app_test.go b/simulation/app_test.go new file mode 100644 index 0000000..e085de5 --- /dev/null +++ b/simulation/app_test.go @@ -0,0 +1,43 @@ +// Copyright 2018 The dexon-consensus-core Authors +// This file is part of the dexon-consensus-core library. +// +// The dexon-consensus-core library is free software: you can redistribute it +// and/or modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation, either version 3 of the License, +// or (at your option) any later version. +// +// The dexon-consensus-core library is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser +// General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with the dexon-consensus-core library. If not, see +// <http://www.gnu.org/licenses/>. + +package simulation + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/dexon-foundation/dexon-consensus-core/core" + "github.com/dexon-foundation/dexon-consensus-core/core/types" +) + +type SimAppSuite struct { + suite.Suite +} + +func (s *SimAppSuite) TestAppInterface() { + var app core.Application + app = newSimApp(types.NodeID{}, nil) + s.NotPanics(func() { + _ = app.(core.Debug) + }) +} + +func TestSimApp(t *testing.T) { + suite.Run(t, new(SimAppSuite)) +} diff --git a/simulation/node.go b/simulation/node.go index 0040184..0a59994 100644 --- a/simulation/node.go +++ b/simulation/node.go @@ -32,7 +32,7 @@ import ( // node represents a node in DexCon. type node struct { - app *simApp + app core.Application gov *simGovernance db blockdb.BlockDatabase |