-
Notifications
You must be signed in to change notification settings - Fork 18
#418 libp2p integration #420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 18 commits
3d65852
2bb1a55
8c7df65
e363289
0edd2b7
634091b
1eb5cc3
61bf760
15bf682
4d68d28
17ac78d
22cdc68
4eb64e3
fddc7a9
eff95d6
848f107
effbd00
f5bde07
14d52e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
{ | ||
"formatters": { | ||
"enable": [ | ||
"gofmt", | ||
"gofumpt", | ||
"goimports" | ||
], | ||
"exclusions": { | ||
"generated": "lax", | ||
"paths": [ | ||
"third_party$", | ||
"builtin$", | ||
"examples$" | ||
] | ||
} | ||
}, | ||
"linters": { | ||
"default": "all", | ||
"disable": [ | ||
"err113", | ||
"errorlint", | ||
"gochecknoglobals", | ||
"gochecknoinits", | ||
"ireturn", | ||
"lll", | ||
"nlreturn", | ||
"paralleltest", | ||
"promlinter", | ||
"tparallel", | ||
"varnamelen", | ||
"wrapcheck", | ||
"wsl", | ||
"testifylint", | ||
"revive", | ||
"recvcheck", | ||
"prealloc", | ||
"depguard", | ||
"nonamedreturns", | ||
"inamedparam", | ||
"exhaustruct" | ||
], | ||
"exclusions": { | ||
"generated": "lax", | ||
"paths": [ | ||
"third_party$", | ||
"builtin$", | ||
"examples$" | ||
], | ||
"presets": [ | ||
"common-false-positives", | ||
"legacy", | ||
"std-error-handling" | ||
], | ||
"rules": [ | ||
{ | ||
"linters": [ | ||
"err113", | ||
"forcetypeassert", | ||
"funlen" | ||
], | ||
"path": "test" | ||
}, | ||
{ | ||
"linters": [ | ||
"revive" | ||
], | ||
"path": "test", | ||
"text": "context-as-argument" | ||
} | ||
] | ||
}, | ||
"settings": { | ||
"cyclop": { | ||
"max-complexity": 15 | ||
}, | ||
"forbidigo": { | ||
"forbid": [ | ||
{ | ||
"pattern": "^[Ee]quals$" | ||
}, | ||
{ | ||
"pattern": "^print.*$" | ||
}, | ||
{ | ||
"pattern": "fmt\\.Print.*" | ||
} | ||
] | ||
}, | ||
"goheader": { | ||
"template-path": ".scripts/copyright-notice", | ||
"values": { | ||
"regexp": { | ||
"ANY_YEAR": "20(19|2\\d)" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"run": { | ||
"modules-download-mode": "readonly" | ||
}, | ||
"version": "2" | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,10 @@ package channel | |
import ( | ||
"encoding/binary" | ||
"fmt" | ||
"math" | ||
"math/rand" | ||
|
||
"github.com/pkg/errors" | ||
"perun.network/go-perun/channel" | ||
) | ||
|
||
|
@@ -44,16 +46,23 @@ func NewRandomAsset(rng *rand.Rand) *Asset { | |
// MarshalBinary marshals the address into its binary representation. | ||
func (a Asset) MarshalBinary() ([]byte, error) { | ||
data := make([]byte, assetLen) | ||
if a.ID < 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason that If not I'd suggest to make it a The only external user I could find was the
|
||
return nil, errors.New("asset ID must be non-negative") | ||
} | ||
byteOrder.PutUint64(data, uint64(a.ID)) | ||
return data, nil | ||
} | ||
|
||
// UnmarshalBinary unmarshals the asset from its binary representation. | ||
func (a *Asset) UnmarshalBinary(data []byte) error { | ||
if len(data) != assetLen { | ||
return fmt.Errorf("unexpected length %d, want %d", len(data), assetLen) //nolint:goerr113 // We do not want to define this as constant error. | ||
return fmt.Errorf("unexpected length %d, want %d", len(data), assetLen) // We do not want to define this as constant error. | ||
} | ||
id := byteOrder.Uint64(data) | ||
if id > math.MaxInt64 { | ||
return fmt.Errorf("asset ID %d is too large", id) | ||
} | ||
a.ID = int64(byteOrder.Uint64(data)) | ||
a.ID = int64(id) | ||
return nil | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be
require.NoError
?assert.NoError
doesn't panic but just returns abool
that isn't checked here.https://github.com/stretchr/testify?tab=readme-ov-file#require-package
From a quick search it looks like we have that in a lot of places.
Recommendation/Suggestion: Keep it as it is now for this PR (bug existed before, too and this one is already big) and fix all of these in a separate PR.