File tree Expand file tree Collapse file tree 8 files changed +34
-5
lines changed
Expand file tree Collapse file tree 8 files changed +34
-5
lines changed Original file line number Diff line number Diff line change 99| Steffen Rattay | [ @rmbrt ] ( https://github.com/rmbrt ) | rmbrt |
1010| Ilja von Hoessle | [ @iljabvh ] ( https://github.com/iljabvh ) | iljabvh |
1111| Jens Winkle | [ @DragonDev1906 ] ( https://github.com/DragonDev1906 ) | jens #4601 |
12+ | Minh Huy Tran | [ @NhoxxKienn ] ( https://github.com/NhoxxKienn ) | NhoxxKienn |
1213
1314## Emeritus Maintainers
1415
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ PolyCrypt GmbH
4343 Oliver Tale-Yazdi <oliver@perun.network>
4444 Ilja von Hoessle <ilja@perun.network>
4545 Jens Winkle <jens@perun.network>
46+ Minh Huy Tran <huy@perun.network>
4647
4748Robert Bosch GmbH
4849 Manoranjith <ponraj.manoranjitha@in.bosch.com>
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ type AppRandomizer interface {
2727 NewRandomData (* rand.Rand ) channel.Data
2828}
2929
30- var appRandomizer AppRandomizer = & MockAppRandomizer {}
30+ var appRandomizer AppRandomizer = NewMockAppRandomizer ()
3131
3232// isAppRandomizerSet tracks whether the AppRandomizer was already set
3333// with `SetAppRandomizer`.
Original file line number Diff line number Diff line change @@ -29,13 +29,13 @@ func TestAppRandomizerSet(t *testing.T) {
2929 assert .False (t , isAppRandomizerSet , "isAppRandomizerSet should be defaulted to false" )
3030
3131 old := appRandomizer
32- assert .NotPanics (t , func () { SetAppRandomizer (& MockAppRandomizer {} ) }, "first SetAppRandomizer() should work" )
32+ assert .NotPanics (t , func () { SetAppRandomizer (NewMockAppRandomizer () ) }, "first SetAppRandomizer() should work" )
3333 assert .True (t , isAppRandomizerSet , "isAppRandomizerSet should be true" )
3434 assert .NotNil (t , appRandomizer , "appRandomizer should not be nil" )
3535 assert .False (t , old == appRandomizer , "appRandomizer should have changed" )
3636
3737 old = appRandomizer
38- assert .Panics (t , func () { SetAppRandomizer (& MockAppRandomizer {} ) }, "second SetAppRandomizer() should panic" )
38+ assert .Panics (t , func () { SetAppRandomizer (NewMockAppRandomizer () ) }, "second SetAppRandomizer() should panic" )
3939 assert .True (t , isAppRandomizerSet , "isAppRandomizerSet should be true" )
4040 assert .NotNil (t , appRandomizer , "appRandomizer should not be nil" )
4141 assert .True (t , old == appRandomizer , "appRandomizer should not have changed" )
Original file line number Diff line number Diff line change @@ -17,11 +17,19 @@ package test
1717import (
1818 "math/rand"
1919
20+ "github.com/google/uuid"
2021 "perun.network/go-perun/channel"
2122)
2223
2324// MockAppRandomizer implements the AppRandomizer interface.
24- type MockAppRandomizer struct {}
25+ type MockAppRandomizer struct {
26+ id uuid.UUID // Unique identifier for each instance
27+ }
28+
29+ // NewMockAppRandomizer creates a new instance of MockAppRandomizer with a unique identifier.
30+ func NewMockAppRandomizer () * MockAppRandomizer {
31+ return & MockAppRandomizer {id : uuid .New ()}
32+ }
2533
2634// NewRandomApp creates a new MockApp with a random address.
2735func (MockAppRandomizer ) NewRandomApp (rng * rand.Rand ) channel.App {
@@ -32,3 +40,8 @@ func (MockAppRandomizer) NewRandomApp(rng *rand.Rand) channel.App {
3240func (MockAppRandomizer ) NewRandomData (rng * rand.Rand ) channel.Data {
3341 return channel .NewMockOp (channel .MockOp (rng .Uint64 ()))
3442}
43+
44+ // Equal returns false for any comparison, ensuring two MockAppRandomizers are always considered different.
45+ func (m * MockAppRandomizer ) Equal (other * MockAppRandomizer ) bool {
46+ return m .id != other .id
47+ }
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ require (
1717 github.com/davecgh/go-spew v1.1.1 // indirect
1818 github.com/golang/snappy v0.0.4 // indirect
1919 github.com/google/go-cmp v0.5.4 // indirect
20+ github.com/google/uuid v1.6.0
2021 github.com/kr/text v0.2.0 // indirect
2122 github.com/pmezard/go-difflib v1.0.0 // indirect
2223 github.com/stretchr/objx v0.1.1 // indirect
Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
1919github.com/google/go-cmp v0.4.0 /go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE =
2020github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M =
2121github.com/google/go-cmp v0.5.4 /go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE =
22+ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0 =
23+ github.com/google/uuid v1.6.0 /go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo =
2224github.com/hpcloud/tail v1.0.0 /go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU =
2325github.com/kr/pretty v0.1.0 /go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo =
2426github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI =
Original file line number Diff line number Diff line change 1414
1515package simple
1616
17- import "perun.network/go-perun/wire"
17+ import (
18+ "math/rand"
19+
20+ "perun.network/go-perun/wire"
21+ "perun.network/go-perun/wire/test"
22+ )
1823
1924func init () {
2025 wire .SetNewAddressFunc (func () wire.Address {
2126 return NewAddress ("" )
2227 })
28+ test .SetNewRandomAddress (func (rng * rand.Rand ) wire.Address {
29+ return NewRandomAddress (rng )
30+ })
31+ test .SetNewRandomAccount (func (rng * rand.Rand ) wire.Account {
32+ return NewRandomAccount (rng )
33+ })
2334}
You can’t perform that action at this time.
0 commit comments