aboutsummaryrefslogtreecommitdiffstats
path: root/core/test
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-10-01 18:19:52 +0800
committerGitHub <noreply@github.com>2018-10-01 18:19:52 +0800
commit9c33b9dc8aa59d414a6697f1e2d036e5581860ee (patch)
tree74a4a77b5c28fa9a550fe1ba40b5b2efac0e7630 /core/test
parent9b78db7a4744176070bf968d50dbebb191b28b69 (diff)
downloaddexon-consensus-9c33b9dc8aa59d414a6697f1e2d036e5581860ee.tar
dexon-consensus-9c33b9dc8aa59d414a6697f1e2d036e5581860ee.tar.gz
dexon-consensus-9c33b9dc8aa59d414a6697f1e2d036e5581860ee.tar.bz2
dexon-consensus-9c33b9dc8aa59d414a6697f1e2d036e5581860ee.tar.lz
dexon-consensus-9c33b9dc8aa59d414a6697f1e2d036e5581860ee.tar.xz
dexon-consensus-9c33b9dc8aa59d414a6697f1e2d036e5581860ee.tar.zst
dexon-consensus-9c33b9dc8aa59d414a6697f1e2d036e5581860ee.zip
core: update data model to reflect new model (#157)
Update data model: 1) Remove witness ack. 2) Add round to block. 3) Update governance interface.
Diffstat (limited to 'core/test')
-rw-r--r--core/test/app.go41
-rw-r--r--core/test/app_test.go5
2 files changed, 5 insertions, 41 deletions
diff --git a/core/test/app.go b/core/test/app.go
index 4cac36c..3ec670c 100644
--- a/core/test/app.go
+++ b/core/test/app.go
@@ -50,10 +50,6 @@ var (
// and delivered are different.
ErrMismatchTotalOrderingAndDelivered = fmt.Errorf(
"mismatch total ordering and delivered sequence")
- // ErrWitnessAckUnknownBlock means the witness ack is acking on the unknown
- // block.
- ErrWitnessAckUnknownBlock = fmt.Errorf(
- "witness ack on unknown block")
)
// AppAckedRecord caches information when this application received
@@ -87,9 +83,6 @@ type App struct {
Delivered map[common.Hash]*AppDeliveredRecord
DeliverSequence common.Hashes
deliveredLock sync.RWMutex
- WitnessAckSequence []*types.WitnessAck
- witnessAckLock sync.RWMutex
- witnessResultChan chan types.WitnessResult
}
// NewApp constructs a TestApp instance.
@@ -100,17 +93,16 @@ func NewApp() *App {
TotalOrderedByHash: make(map[common.Hash]*AppTotalOrderRecord),
Delivered: make(map[common.Hash]*AppDeliveredRecord),
DeliverSequence: common.Hashes{},
- witnessResultChan: make(chan types.WitnessResult),
}
}
-// PreparePayload implements Application interface.
-func (app *App) PreparePayload(position types.Position) []byte {
- return []byte{}
+// PrepareBlock implements Application interface.
+func (app *App) PrepareBlock(position types.Position) ([]byte, []byte) {
+ return []byte{}, []byte{}
}
-// VerifyPayload implements Application.
-func (app *App) VerifyPayload(payload []byte) bool {
+// VerifyBlock implements Application.
+func (app *App) VerifyBlock(block *types.Block) bool {
return true
}
@@ -157,20 +149,6 @@ func (app *App) BlockDelivered(block types.Block) {
app.DeliverSequence = append(app.DeliverSequence, block.Hash)
}
-// BlockProcessedChan returns a channel to receive the block hashes that have
-// finished processing by the application.
-func (app *App) BlockProcessedChan() <-chan types.WitnessResult {
- return app.witnessResultChan
-}
-
-// WitnessAckDelivered implements Application interface.
-func (app *App) WitnessAckDelivered(witnessAck *types.WitnessAck) {
- app.witnessAckLock.Lock()
- defer app.witnessAckLock.Unlock()
-
- app.WitnessAckSequence = append(app.WitnessAckSequence, witnessAck)
-}
-
// Compare performs these checks against another App instance
// and return erros if not passed:
// - deliver sequence by comparing block hashes.
@@ -256,15 +234,6 @@ Loop:
// by total ordering.
return ErrMismatchTotalOrderingAndDelivered
}
-
- // Make sure that witnessAck is acking the correct block.
- app.witnessAckLock.RLock()
- defer app.witnessAckLock.RUnlock()
- for _, witnessAck := range app.WitnessAckSequence {
- if _, exists := app.Delivered[witnessAck.WitnessBlockHash]; !exists {
- return ErrWitnessAckUnknownBlock
- }
- }
return nil
}
diff --git a/core/test/app_test.go b/core/test/app_test.go
index 9d35c67..baea838 100644
--- a/core/test/app_test.go
+++ b/core/test/app_test.go
@@ -165,11 +165,6 @@ func (s *AppTestSuite) TestVerify() {
// Witness ack on unknown block.
app5 := NewApp()
s.setupAppByTotalOrderDeliver(app5, s.to1)
- app5.WitnessAckDelivered(&types.WitnessAck{
- Hash: common.NewRandomHash(),
- WitnessBlockHash: common.NewRandomHash(),
- })
- req.Equal(ErrWitnessAckUnknownBlock, app5.Verify())
}
func TestApp(t *testing.T) {