Skip to content
Closed
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
3 changes: 2 additions & 1 deletion devnet-sdk/testing/testlib/validators/lowlevel.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func lowLevelSystemValidator(sysMarker interface{}) systest.PreconditionValidato
}

func AcquireLowLevelSystem() (LowLevelSystemGetter, systest.PreconditionValidator) {
sysMarker := &struct{}{}
sysMarker := newSentinelMarker()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should just be able to use new(byte) instead of &struct{}{} instead of keeping a global counter or?

I made that fix and validated it by a run in the external devnet-sdk testing repo, see description in the PR #14514

fmt.Printf("low level system: %p\n", sysMarker)
validator := lowLevelSystemValidator(sysMarker)
return func(ctx context.Context) system.LowLevelSystem {
return ctx.Value(sysMarker).(system.LowLevelSystem)
Expand Down
17 changes: 17 additions & 0 deletions devnet-sdk/testing/testlib/validators/sentinel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package validators

import "sync/atomic"

var (
sentinelID atomic.Uint64
)

type sentinelMarker struct {
id uint64
}

func newSentinelMarker() *sentinelMarker {
return &sentinelMarker{
id: sentinelID.Add(1),
}
}
3 changes: 2 additions & 1 deletion devnet-sdk/testing/testlib/validators/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ func walletFundsValidator(chainIdx uint64, minFunds types.Balance, userMarker in
}

func AcquireL2WalletWithFunds(chainIdx uint64, minFunds types.Balance) (WalletGetter, systest.PreconditionValidator) {
userMarker := &struct{}{}
userMarker := newSentinelMarker()
fmt.Printf("wallet: %p\n", userMarker)
validator := walletFundsValidator(chainIdx, minFunds, userMarker)
return func(ctx context.Context) system.Wallet {
return ctx.Value(userMarker).(system.Wallet)
Expand Down