Skip to content

Commit

Permalink
Merge cd2d39b into 3c9ec62
Browse files Browse the repository at this point in the history
  • Loading branch information
divyakoshy committed Jul 12, 2018
2 parents 3c9ec62 + cd2d39b commit 6e88c6c
Show file tree
Hide file tree
Showing 10 changed files with 277 additions and 134 deletions.
2 changes: 1 addition & 1 deletion .travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

go build ./...
GOMAXPROCS=1 CI=true ginkgo -v --race --cover --coverprofile coverprofile.out ./...
covermerge crypto/coverprofile.out dht/coverprofile.out dispatch/coverprofile.out grpc/coverprofile.out http/coverprofile.out http/adapter/coverprofile.out identity/coverprofile.out ingress/coverprofile.out leveldb/coverprofile.out logger/coverprofile.out ome/coverprofile.out order/coverprofile.out orderbook/coverprofile.out shamir/coverprofile.out smpc/coverprofile.out stackint/coverprofile.out stream/coverprofile.out swarm/coverprofile.out > coverprofile.out
covermerge crypto/coverprofile.out dht/coverprofile.out dispatch/coverprofile.out grpc/coverprofile.out http/coverprofile.out http/adapter/coverprofile.out identity/coverprofile.out leveldb/coverprofile.out logger/coverprofile.out ome/coverprofile.out order/coverprofile.out orderbook/coverprofile.out shamir/coverprofile.out smpc/coverprofile.out stackint/coverprofile.out stream/coverprofile.out swarm/coverprofile.out > coverprofile.out

sed -i '/.pb.go/d' coverprofile.out
sed -i '/bindings/d' coverprofile.out
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ script:
# - golint -set_exit_status `go list ./... | grep -Ev "(stackint/asm|vendor)"`
# - golint `go list ./... | grep -Ev "(stackint/asm|vendor)"`
- ginkgo --race --cover --coverprofile coverprofile.out ./...
- covermerge crypto/coverprofile.out dht/coverprofile.out dispatch/coverprofile.out grpc/coverprofile.out http/coverprofile.out http/adapter/coverprofile.out identity/coverprofile.out ingress/coverprofile.out leveldb/coverprofile.out logger/coverprofile.out ome/coverprofile.out order/coverprofile.out orderbook/coverprofile.out shamir/coverprofile.out smpc/coverprofile.out stackint/coverprofile.out stream/coverprofile.out swarm/coverprofile.out > coverprofile.out
- covermerge crypto/coverprofile.out dht/coverprofile.out dispatch/coverprofile.out grpc/coverprofile.out http/coverprofile.out http/adapter/coverprofile.out identity/coverprofile.out leveldb/coverprofile.out logger/coverprofile.out ome/coverprofile.out order/coverprofile.out orderbook/coverprofile.out shamir/coverprofile.out smpc/coverprofile.out stackint/coverprofile.out stream/coverprofile.out swarm/coverprofile.out > coverprofile.out
- sed -i '/.pb.go/d' coverprofile.out # autogenerated files
- sed -i '/bindings/d' coverprofile.out # autogenerated files
- sed -i '/cmd/d' coverprofile.out # command-line files
Expand Down
2 changes: 1 addition & 1 deletion ome/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var _ = Describe("Matcher", func() {
smpcer := testutils.NewSmpc()
matcher := NewMatcher(store, smpcer)

numTrials := 256
numTrials := 1024
numMatches := 0
for i := 0; i < numTrials; i++ {
com := NewComputation([32]byte{byte(i)}, buyFragment, sellFragment, ComputationStateNil, true)
Expand Down
20 changes: 1 addition & 19 deletions ome/ome_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ome_test
import (
"errors"
"fmt"
"math/big"
"os"
"sync"
"time"
Expand Down Expand Up @@ -49,9 +48,8 @@ var _ = Describe("Ome", func() {

BeforeEach(func() {
done = make(chan struct{})
addr, err = testutils.RandomAddress()
addr, epoch, err = testutils.RandomEpoch(0)
Ω(err).ShouldNot(HaveOccurred())
epoch = newEpoch(0, addr)

computationsGenerator = NewComputationGenerator()
rsaKey, err := crypto.RandomRsaKey()
Expand Down Expand Up @@ -270,19 +268,3 @@ func (binder *omeBinder) setOrderStatus(orderID order.ID, status order.Status) e

return nil
}

// newEpoch returns a new epoch with only one pod and one darknode.
func newEpoch(i int, node identity.Address) registry.Epoch {
return registry.Epoch{
Hash: testutils.Random32Bytes(),
Pods: []registry.Pod{
{
Position: 0,
Hash: testutils.Random32Bytes(),
Darknodes: []identity.Address{node},
},
},
Darknodes: []identity.Address{node},
BlockNumber: big.NewInt(int64(i)),
}
}
1 change: 1 addition & 0 deletions orderbook/orderbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ func (orderbook *orderbook) routeOrderFragment(ctx context.Context, orderFragmen
if orderbook.syncerCurrDone == nil {
return nil
}

select {
case <-ctx.Done():
return ctx.Err()
Expand Down
24 changes: 21 additions & 3 deletions orderbook/orderbook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/republicprotocol/republic-go/identity"
"github.com/republicprotocol/republic-go/leveldb"
. "github.com/republicprotocol/republic-go/orderbook"
"github.com/republicprotocol/republic-go/registry"
Expand Down Expand Up @@ -89,7 +90,7 @@ var _ = Describe("Orderbook", func() {
Ω(err).ShouldNot(HaveOccurred())

// Create mock syncer and storer
syncer := testutils.NewSyncer(numberOfOrders)
// syncer := testutils.NewSyncer(numberOfOrders)
storer, err := leveldb.NewStore("./data.out", 72*time.Hour)
Expect(err).ShouldNot(HaveOccurred())
defer func() {
Expand All @@ -99,11 +100,11 @@ var _ = Describe("Orderbook", func() {
// Create orderbook
orderbook := NewOrderbook(rsaKey, storer.OrderbookPointerStore(), storer.OrderbookOrderStore(), storer.OrderbookOrderFragmentStore(), testutils.NewMockContractBinder(), time.Hour, 100)

Ω(syncer.HasSynced()).Should(BeFalse())
// Ω(syncer.HasSynced()).Should(BeFalse())
doneChan := make(<-chan struct{})
changeset, _ := orderbook.Sync(doneChan)
Ω(len(changeset)).Should(BeZero())
Ω(syncer.HasSynced()).Should(BeTrue())
// Ω(syncer.HasSynced()).Should(BeTrue())
})
})
})
Expand Down Expand Up @@ -299,3 +300,20 @@ func (binder *orderbookBinder) setOrderStatus(orderID order.ID, status order.Sta
}
return nil
}

// newEpoch returns a new epoch with only one pod and one darknode.
func newEpoch(i int, node identity.Address) registry.Epoch {
return registry.Epoch{
Hash: testutils.Random32Bytes(),
Pods: []registry.Pod{
{
Position: 0,
Hash: testutils.Random32Bytes(),
Darknodes: []identity.Address{node},
},
},
Darknodes: []identity.Address{node},
BlockNumber: big.NewInt(int64(i)),
BlockInterval: big.NewInt(int64(2)),
}
}
1 change: 0 additions & 1 deletion orderbook/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ func (syncer *syncer) syncOpens(done <-chan struct{}, notifications chan<- Notif
}

func (syncer *syncer) insertOrder(orderID order.ID, orderStatus order.Status, trader string, blockNumber uint64, done <-chan struct{}, notifications chan<- Notification, errs chan<- error) {

// Store the order
if err := syncer.orderStore.PutOrder(orderID, orderStatus, trader, blockNumber); err != nil {
select {
Expand Down

0 comments on commit 6e88c6c

Please sign in to comment.