Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions backend/ethereum/channel/conclude_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,13 @@ func TestAdjudicator_ConcludeWithSubChannels(t *testing.T) {
// 0. setup

const (
numParts = 2
maxCountSubChannels = 3
maxCountSubSubChannels = 3
maxChallengeDuration = 3600
numParts = 2
maxCountSubChannels = 3
maxCountSubSubChannels = 3
minFundingTXBlocksTimeout = 200
minChallengeDuration = minFundingTXBlocksTimeout
maxChallengeDuration = 3600
challengeDurationSpread = maxChallengeDuration - minChallengeDuration
)
ctx, cancel := newDefaultTestContext()
defer cancel()
Expand All @@ -121,7 +124,7 @@ func TestAdjudicator_ConcludeWithSubChannels(t *testing.T) {
accounts = s.Accs
participants = s.Parts
asset = s.Asset
challengeDuration = uint64(rng.Intn(maxChallengeDuration))
challengeDuration = uint64(rng.Intn(challengeDurationSpread) + minChallengeDuration)
makeRandomChannel = func(rng *rand.Rand, ledger bool) paramsAndState {
return makeRandomChannel(rng, participants, asset, challengeDuration, ledger)
}
Expand Down
15 changes: 10 additions & 5 deletions backend/ethereum/channel/test/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ type SimulatedBackend struct {
backends.SimulatedBackend
sbMtx sync.Mutex // protects SimulatedBackend

faucetKey *ecdsa.PrivateKey
faucetAddr common.Address
clockMu sync.Mutex // Mutex for clock adjustments. Locked by SimTimeouts.
mining chan struct{} // Used for auto-mining blocks.
commitTx bool // Whether each transaction is committed.
faucetKey *ecdsa.PrivateKey
faucetAddr common.Address
clockMu sync.Mutex // Mutex for clock adjustments. Locked by SimTimeouts.
mining chan struct{} // Used for auto-mining blocks.
stoppedMining chan struct{} // For making sure that mining stopped.
commitTx bool // Whether each transaction is committed.
}

type (
Expand Down Expand Up @@ -146,9 +147,11 @@ func (s *SimulatedBackend) StartMining(interval time.Duration) {
}

s.mining = make(chan struct{})
s.stoppedMining = make(chan struct{})
go func() {
log.Trace("Started mining")
defer log.Trace("Stopped mining")
defer close(s.stoppedMining)

for {
s.Commit()
Expand All @@ -165,8 +168,10 @@ func (s *SimulatedBackend) StartMining(interval time.Duration) {

// StopMining stops the auto-mining of the simulated blockchain.
// Must be called exactly once to free resources iff `StartMining` was called.
// Waits until the auto-mining routine terminates.
func (s *SimulatedBackend) StopMining() {
close(s.mining)
<-s.stoppedMining
}

// Reorg applies a chain reorg.
Expand Down
4 changes: 1 addition & 3 deletions backend/ethereum/subscription/resistanteventsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,6 @@ func (s *ResistantEventSub) isFinal(event *Event) bool {
// Close closes the sub and the underlying `EventSub`.
// Can be called more than once. Is thread safe.
func (s *ResistantEventSub) Close() {
if err := s.closer.Close(); err != nil && !pkgsync.IsAlreadyClosedError(err) {
log.WithError(err).Error("could not close EventSub")
}
s.closer.Close() // Silently ignore repeated close calls, as it is allowed in this function's specification.
// NOTE: The underlying `EventSub` is closed in the `OnCloseAlways` hook.
}