From 22e70f6da486ed6796a493f25e04679b9afa1439 Mon Sep 17 00:00:00 2001 From: Wei-Ning Huang Date: Wed, 19 Sep 2018 18:48:41 +0800 Subject: core: rename Notary (Acks) to Witness (#118) --- core/test/app.go | 32 ++++++++++++++++---------------- core/test/app_test.go | 10 +++++----- 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'core/test') diff --git a/core/test/app.go b/core/test/app.go index 57fc467..e9ef871 100644 --- a/core/test/app.go +++ b/core/test/app.go @@ -50,10 +50,10 @@ var ( // and delivered are different. ErrMismatchTotalOrderingAndDelivered = fmt.Errorf( "mismatch total ordering and delivered sequence") - // ErrNotaryAckUnknownBlock means the notary ack is acking on the unknown + // ErrWitnessAckUnknownBlock means the witness ack is acking on the unknown // block. - ErrNotaryAckUnknownBlock = fmt.Errorf( - "notary ack on unknown block") + ErrWitnessAckUnknownBlock = fmt.Errorf( + "witness ack on unknown block") ) // AppAckedRecord caches information when this application received @@ -87,8 +87,8 @@ type App struct { Delivered map[common.Hash]*AppDeliveredRecord DeliverSequence common.Hashes deliveredLock sync.RWMutex - NotaryAckSequence []*types.NotaryAck - notaryAckLock sync.RWMutex + WitnessAckSequence []*types.WitnessAck + witnessAckLock sync.RWMutex } // NewApp constructs a TestApp instance. @@ -155,12 +155,12 @@ func (app *App) DeliverBlock(blockHash common.Hash, timestamp time.Time) { app.DeliverSequence = append(app.DeliverSequence, blockHash) } -// NotaryAckDeliver implements Application interface. -func (app *App) NotaryAckDeliver(notaryAck *types.NotaryAck) { - app.notaryAckLock.Lock() - defer app.notaryAckLock.Unlock() +// WitnessAckDeliver implements Application interface. +func (app *App) WitnessAckDeliver(witnessAck *types.WitnessAck) { + app.witnessAckLock.Lock() + defer app.witnessAckLock.Unlock() - app.NotaryAckSequence = append(app.NotaryAckSequence, notaryAck) + app.WitnessAckSequence = append(app.WitnessAckSequence, witnessAck) } // Compare performs these checks against another App instance @@ -249,12 +249,12 @@ Loop: return ErrMismatchTotalOrderingAndDelivered } - // Make sure that notaryAck is acking the correct block. - app.notaryAckLock.RLock() - defer app.notaryAckLock.RUnlock() - for _, notaryAck := range app.NotaryAckSequence { - if _, exists := app.Delivered[notaryAck.NotaryBlockHash]; !exists { - return ErrNotaryAckUnknownBlock + // 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 6966de5..0003852 100644 --- a/core/test/app_test.go +++ b/core/test/app_test.go @@ -153,14 +153,14 @@ func (s *AppTestSuite) TestVerify() { app4.StronglyAcked(hash) app4.TotalOrderingDeliver(common.Hashes{hash}, false) s.deliverBlockWithTimeFromSequenceLength(app4, hash) - // Notary ack on unknown block. + // Witness ack on unknown block. app5 := NewApp() s.setupAppByTotalOrderDeliver(app5, s.to1) - app5.NotaryAckDeliver(&types.NotaryAck{ - Hash: common.NewRandomHash(), - NotaryBlockHash: common.NewRandomHash(), + app5.WitnessAckDeliver(&types.WitnessAck{ + Hash: common.NewRandomHash(), + WitnessBlockHash: common.NewRandomHash(), }) - req.Equal(ErrNotaryAckUnknownBlock, app5.Verify()) + req.Equal(ErrWitnessAckUnknownBlock, app5.Verify()) } func TestApp(t *testing.T) { -- cgit v1.2.3