Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3d65852
feat: add aux attribute in channel.Params
NhoxxKienn Jan 23, 2025
2bb1a55
feat(adjudicate): gather state map switchs to gather signed states
NhoxxKienn Feb 26, 2025
8c7df65
feat(vc_test): add aux params to virtual channel test for utxo chains
NhoxxKienn Apr 2, 2025
e363289
feat(vc test): send parent ID in aux instead for utxo chains
NhoxxKienn Apr 2, 2025
0edd2b7
fix(vc test): fix aux generation in virtual channel test
NhoxxKienn Apr 2, 2025
634091b
feat(test/virtualchannel): add wait time for processing opening virtu…
NhoxxKienn Apr 10, 2025
1eb5cc3
feat: add log and proper secondary settle for virtual channel test di…
NhoxxKienn Apr 10, 2025
61bf760
feat: add additional payment channel test setup
NhoxxKienn Apr 14, 2025
15bf682
feat: add proper clean up for virtual channel optimistic test
NhoxxKienn Apr 15, 2025
4d68d28
feat: add client's handler for virtual channel test cleanup
NhoxxKienn Apr 15, 2025
17ac78d
Merge branch 'main' into nervos_ckb
NhoxxKienn Apr 24, 2025
22cdc68
refactor(lint): update and refactor golangci-lint
NhoxxKienn Apr 25, 2025
4eb64e3
feat(wire/net/libp2p): add initial package libp2p
NhoxxKienn Apr 28, 2025
fddc7a9
feat(go.mod): update go dependencies
NhoxxKienn Apr 28, 2025
eff95d6
feat(libp2p): add libp2p account, address
NhoxxKienn Apr 28, 2025
848f107
feat(libp2p): add dialer and listener
NhoxxKienn Apr 29, 2025
effbd00
feat(libp2p): add exchange addr tests
NhoxxKienn Apr 29, 2025
f5bde07
feat(wire/net): add bus test for libp2p and simple
NhoxxKienn Apr 30, 2025
14d52e5
Merge branch 'main' into 418_libp2p_integration
NhoxxKienn May 21, 2025
8cd8f57
fix(all): changes according to PR's review
NhoxxKienn Jul 14, 2025
bbf0d26
Merge branch 'main' into nervos_ckb
NhoxxKienn Jul 14, 2025
d541e25
fix: clear linting problem
NhoxxKienn Jul 14, 2025
a5c5eb3
chore: fix ci problem
NhoxxKienn Jul 15, 2025
83be060
Revert: feat(adjudicate): stateMap to signedState: This reverts commi…
NhoxxKienn Jul 29, 2025
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
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ on:
release:

env:
go-version: 1.18
go-version: 1.23

jobs:
check-copyright:
name: Copyright
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Authors
Expand All @@ -26,20 +26,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Check vanity import
run: .scripts/check-vanity-imports.sh $GITHUB_WORKSPACE

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ${{ env.go-version }}

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v7
with:
version: v1.45
version: v2.1

- name: Lint proto files
uses: plexsystems/protolint-action@v0.6.0
Expand Down
103 changes: 103 additions & 0 deletions .golangci.json
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"
}
81 changes: 0 additions & 81 deletions .golangci.yml

This file was deleted.

1 change: 1 addition & 0 deletions apps/payment/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func (a *App) NewData() channel.Data {
// participants.
func (a *App) ValidTransition(_ *channel.Params, from, to *channel.State, actor channel.Index) error {
assertNoData(to)

for i, asset := range from.Balances {
for j, bal := range asset {
if int(actor) == j && bal.Cmp(to.Balances[i][j]) == -1 {
Expand Down
14 changes: 9 additions & 5 deletions apps/payment/app_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,22 @@ func TestApp_ValidInit(t *testing.T) {
app := new(App)

nildata := &channel.State{Data: nil}

assert.Panics(func() { app.ValidInit(nil, nildata) }) //nolint:errcheck
wrongdata := &channel.State{Data: new(channel.MockOp)}

assert.Panics(func() { app.ValidInit(nil, wrongdata) }) //nolint:errcheck

data := &channel.State{Data: Data()}
assert.Nil(app.ValidInit(nil, data))
assert.NoError(app.ValidInit(nil, data))
}

func TestApp_ValidTransition(t *testing.T) {
type (
alloc = [][]int64
to struct {
alloc

valid int // the valid actor index, or -1 if there's no valid actor
}
)
Expand Down Expand Up @@ -93,9 +96,9 @@ func TestApp_ValidTransition(t *testing.T) {
test.WithBalances(asBalances(tt.from...)...),
)
numParticipants := len(tt.from[0])
for i := 0; i < numParticipants; i++ {
for i := range numParticipants {
// valid self-transition
assert.NoError(app.ValidTransition(nil, from, from, channel.Index(i)))
assert.NoError(app.ValidTransition(nil, from, from, channel.Index(i))) //nolint:gosec
}

for _, tto := range tt.tos {
Expand All @@ -104,8 +107,8 @@ func TestApp_ValidTransition(t *testing.T) {
test.WithAppData(Data()),
test.WithBalances(asBalances(tto.alloc...)...),
)
for i := 0; i < numParticipants; i++ {
err := app.ValidTransition(nil, from, to, channel.Index(i))
for i := range numParticipants {
err := app.ValidTransition(nil, from, to, channel.Index(i)) //nolint:gosec
if i == tto.valid {
assert.NoError(err)
} else {
Expand All @@ -120,6 +123,7 @@ func TestApp_ValidTransition(t *testing.T) {
from := test.NewRandomState(rng, test.WithApp(app), test.WithBalances(asBalances(tests[0].from...)...), test.WithNumAssets(len(tests[0].from)))
to := from.Clone()
to.Data = nil

assert.Panics(t, func() { app.ValidTransition(nil, from, to, 0) }) //nolint:errcheck
})

Expand Down
3 changes: 2 additions & 1 deletion apps/payment/randomizer_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

_ "perun.network/go-perun/backend/sim" // backend init
"perun.network/go-perun/channel"
Expand All @@ -31,7 +32,7 @@ func TestRandomizer(t *testing.T) {
app := r.NewRandomApp(rng, channel.TestBackendID)
channel.RegisterApp(app)
regApp, err := channel.Resolve(app.Def())
assert.NoError(t, err)
require.NoError(t, err)
assert.True(t, app.Def().Equal(regApp.Def()))
assert.True(t, IsData(r.NewRandomData(rng)))
}
4 changes: 2 additions & 2 deletions apps/payment/resolver_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestResolver(t *testing.T) {
channel.RegisterAppResolver(def.Equal, &Resolver{})

app, err := channel.Resolve(def)
assert.NoError(err)
require.NoError(err)
require.NotNil(app)
assert.True(def.Equal(app.Def()))
}
Expand All @@ -47,7 +47,7 @@ func TestData(t *testing.T) {
assert.NotPanics(func() {
data := Data()
_, err := data.MarshalBinary()
assert.Nil(err)
assert.NoError(err)
})

assert.NotPanics(func() {
Expand Down
12 changes: 6 additions & 6 deletions backend/sim/channel/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ type AppID struct {
*wallet.Address
}

// NewRandomAppID generates a new random app identifier.
func NewRandomAppID(rng *rand.Rand) AppID {
addr := wallet.NewRandomAddress(rng)
return AppID{Address: addr}
}

// Equal returns whether the object is equal to the given object.
func (id AppID) Equal(b channel.AppID) bool {
bTyped, ok := b.(AppID)
Expand All @@ -44,9 +50,3 @@ func (id AppID) Key() channel.AppIDKey {
}
return channel.AppIDKey(b)
}

// NewRandomAppID generates a new random app identifier.
func NewRandomAppID(rng *rand.Rand) AppID {
addr := wallet.NewRandomAddress(rng)
return AppID{Address: addr}
}
10 changes: 5 additions & 5 deletions backend/sim/channel/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,29 @@ var byteOrder = binary.BigEndian

// Asset simulates a `channel.Asset` by only containing an `ID`.
type Asset struct {
ID int64
ID uint64
}

var _ channel.Asset = new(Asset)

// NewRandomAsset returns a new random sim Asset.
func NewRandomAsset(rng *rand.Rand) *Asset {
return &Asset{ID: rng.Int63()}
return &Asset{ID: rng.Uint64()}
}

// MarshalBinary marshals the address into its binary representation.
func (a Asset) MarshalBinary() ([]byte, error) {
data := make([]byte, assetLen)
byteOrder.PutUint64(data, uint64(a.ID))
byteOrder.PutUint64(data, 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.
}
a.ID = int64(byteOrder.Uint64(data))
a.ID = byteOrder.Uint64(data)
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions backend/sim/channel/asset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

func Test_Asset_GenericMarshaler(t *testing.T) {
rng := pkgtest.Prng(t)
for n := 0; n < 10; n++ {
test.GenericMarshalerTest(t, &channel.Asset{ID: rng.Int63()})
for range 10 {
test.GenericMarshalerTest(t, &channel.Asset{ID: rng.Uint64()})
}
}
Loading