Skip to content
Open
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
57 changes: 51 additions & 6 deletions .github/workflows/run_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:

jobs:
run-integration-test:
setup:
runs-on: ubuntu-latest
steps:
- name: Check out gnoswap repo
Expand All @@ -24,18 +24,63 @@ jobs:
with:
go-version: "1.24"

- name: Build gno binary
run: |
cd gno
go build -o gno-binary ./gnovm/cmd/gno

- name: Upload gno artifacts
uses: actions/upload-artifact@v4
with:
name: gno-integration-build
path: |
gno/
retention-days: 1

run-integration-test:
needs: setup
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: "base"
categories: "base"
- name: "upgradable"
categories: "upgradable"
- name: "gov-launchpad"
categories: "gov,launchpad"
- name: "others"
categories: "router,pool,position,staker,root"
steps:
- name: Check out gnoswap repo
uses: actions/checkout@v4

- name: Download gno artifacts
uses: actions/download-artifact@v4
with:
name: gno-integration-build
path: ./gno

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
cache: true
cache-dependency-path: gno/go.sum

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install gno
- name: Install gno from artifacts
run: |
cd gno
make install.gno
chmod +x gno/gno-binary
sudo mv gno/gno-binary /usr/local/bin/gno

- name: Run setup.py
run: python3 setup.py --exclude-tests -w .

- name: Run integration tests
run: ./scripts/all-integration-tests.sh ./gno/gno.land/pkg/integration . --skip
- name: "Run integration tests (${{ matrix.name }})"
run: ./scripts/all-integration-tests.sh ./gno/gno.land/pkg/integration . --skip --category=${{ matrix.categories }}
52 changes: 41 additions & 11 deletions .github/workflows/run_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
pull_request:

jobs:
generate-matrix:
setup:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
Expand All @@ -14,7 +14,7 @@
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@d354de180d0c9e813cfddfcbdc079945d4be589b # v1.275.0
with:
ruby-version: 3.4

Expand All @@ -30,42 +30,72 @@
chmod +x .github/scripts/generate_matrix.rb
echo "matrix=$(ruby .github/scripts/generate_matrix.rb contract tests/scenario)" >> $GITHUB_OUTPUT

- name: Check out gno
uses: actions/checkout@v4
with:
repository: gnoswap-labs/gno
ref: master
path: ./gno

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: Build gno binary
run: |
cd gno
go build -o gno-binary ./gnovm/cmd/gno

- name: Upload gno artifacts
uses: actions/upload-artifact@v4
with:
name: gno-build
path: gno/
retention-days: 1

test-gnoswap:
needs: generate-matrix
needs: setup
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{fromJson(needs.generate-matrix.outputs.matrix)}}
matrix: ${{fromJson(needs.setup.outputs.matrix)}}

steps:
- name: Check out gnoswap repo
uses: actions/checkout@v4

- name: Check out gno(master - before change std prefix)
uses: actions/checkout@v4
- name: Download gno artifacts
uses: actions/download-artifact@v4
with:
repository: gnoswap-labs/gno
ref: master
name: gno-build
path: ./gno

- name: Set up Ruby
uses: ruby/setup-ruby@d354de180d0c9e813cfddfcbdc079945d4be589b # v1.275.0
with:
ruby-version: 3.4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
cache: true
cache-dependency-path: gno/go.sum

- name: Install gno
- name: Install gno from artifacts
run: |
cd gno
make install.gno
chmod +x gno/gno-binary
sudo mv gno/gno-binary /usr/local/bin/gno

- name: Update fuzz test seed
run: |
chmod +x .github/scripts/update_fuzz_seed.sh
.github/scripts/update_fuzz_seed.sh

- name: "Run tests for ${{ matrix.name }}"
run: |
chmod +x .github/scripts/run_tests.rb
ruby .github/scripts/run_tests.rb \
-f "${{ matrix.folder }}" \
-r "/home/runner/work/gnoswap/gnoswap/gno"

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
2 changes: 0 additions & 2 deletions contract/r/gnoswap/test/fuzz/gnomod.toml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fuzz
package math

import (
"math"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fuzz
package math

import (
"strconv"
Expand Down
2 changes: 2 additions & 0 deletions contract/r/gnoswap/test/fuzz/math/gnomod.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module = "gno.land/r/gnoswap/test/fuzz/math"
gno = "0.9"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fuzz
package math

import (
"gno.land/p/gnoswap/fuzz"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fuzz
package math

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fuzz
package math

import (
"gno.land/p/gnoswap/fuzz"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fuzz
package math

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fuzz
package math

import (
"gno.land/p/gnoswap/fuzz"
Expand Down Expand Up @@ -68,16 +68,19 @@ func (p *int256AddOverflowParams) IsValid() bool {
// - Both positive and sum > MaxInt256
// - Both negative and sum < MinInt256
if x.Sign() >= 0 && y.Sign() >= 0 {
// Both non-negative: check if x + y > MaxInt256
// Both non-negative: check if x + y > MaxInt256
maxInt := i256.MaxInt256()
remain := new(i256.Int).Sub(maxInt, y)
return x.Lte(remain)
} else if x.Sign() < 0 && y.Sign() < 0 {
// Both negative: check if x + y < MinInt256
}

if x.Sign() < 0 && y.Sign() < 0 {
// Both negative: check if x + y < MinInt256
minInt := i256.MinInt256()
remain := new(i256.Int).Sub(minInt, y)
return x.Gte(remain)
}

// Different signs: no overflow possible
return true
}
Expand Down Expand Up @@ -164,17 +167,20 @@ func (p *int256SubOverflowParams) IsValid() bool {
// - x positive, y negative, and x - y > MaxInt256
// - x negative, y positive, and x - y < MinInt256
if x.Sign() >= 0 && y.Sign() < 0 {
// x - (-|y|) = x + |y|, check if > MaxInt256
// x - (-|y|) = x + |y|, check if > MaxInt256
maxInt := i256.MaxInt256()
negY := new(i256.Int).Neg(y)
remain := new(i256.Int).Sub(maxInt, negY)
return x.Lte(remain)
} else if x.Sign() < 0 && y.Sign() > 0 {
// x - y where x < 0, y > 0, check if < MinInt256
}

if x.Sign() < 0 && y.Sign() > 0 {
// x - y where x < 0, y > 0, check if < MinInt256
minInt := i256.MinInt256()
remain := new(i256.Int).Add(minInt, y)
return x.Gte(remain)
}

// Same signs: no overflow possible
return true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fuzz
package math

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fuzz
package math

import (
"gno.land/p/gnoswap/fuzz"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fuzz
package math

import (
"gno.land/p/gnoswap/fuzz"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fuzz
package math

import (
"math/bits"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fuzz
package math

import (
"gno.land/p/gnoswap/fuzz"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fuzz
package math

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fuzz
package math

import (
"gno.land/p/gnoswap/fuzz"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fuzz
package math

import (
"testing"
Expand Down
Loading
Loading