diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 00000000..6a6e01c1
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,2 @@
+Dockerfile
+build
diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml
new file mode 100644
index 00000000..79b5d544
--- /dev/null
+++ b/.gitea/workflows/build.yml
@@ -0,0 +1,17 @@
+name: Build
+on:
+ pull_request:
+ branches:
+ - main
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions/setup-go@v3
+ with:
+ go-version: 1.21
+ check-latest: true
+ - run: |
+ make build
diff --git a/.gitea/workflows/docker-image.yml b/.gitea/workflows/docker-image.yml
new file mode 100644
index 00000000..528c801a
--- /dev/null
+++ b/.gitea/workflows/docker-image.yml
@@ -0,0 +1,28 @@
+name: Publish on release
+on:
+ release:
+ types: [published]
+jobs:
+ build:
+ name: Run docker build and publish
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Run docker build
+ run: docker build -t cerc-io/laconic2d -f Dockerfile .
+ - name: Get the version
+ id: vars
+ run: |
+ echo ::set-output name=sha::$(echo ${GITHUB_SHA:0:7})
+ echo ::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/})
+ - name: Tag docker image
+ run: docker tag cerc-io/laconic2d git.vdb.to/cerc-io/laconic2d/laconic2d:${{steps.vars.outputs.sha}}
+ - name: Tag docker image
+ run: docker tag git.vdb.to/cerc-io/laconic2d/laconic2d:${{steps.vars.outputs.sha}} git.vdb.to/cerc-io/laconic2d/laconic2d:${{steps.vars.outputs.tag}}
+ - name: Docker Login
+ run: echo ${{ secrets.CICD_PUBLISH_TOKEN }} | docker login https://git.vdb.to -u cerccicd --password-stdin
+ - name: Docker Push
+ run: docker push git.vdb.to/cerc-io/laconic2d/laconic2d:${{steps.vars.outputs.sha}}
+ - name: Docker Push TAGGED
+ run: docker push git.vdb.to/cerc-io/laconic2d/laconic2d:${{steps.vars.outputs.tag}}
+
diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yml
new file mode 100644
index 00000000..82c56a7b
--- /dev/null
+++ b/.gitea/workflows/lint.yml
@@ -0,0 +1,27 @@
+name: Lint
+# Lint runs golangci-lint over the entire repository This workflow is
+# run on every pull request and push to main The `golangci` will pass without
+# running if no *.{go, mod, sum} files have been changed.
+on:
+ pull_request:
+ push:
+ branches:
+ - main
+jobs:
+ golangci:
+ name: Run golangci-lint
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+ steps:
+ # Required: setup-go, for all versions v3.0.0+ of golangci-lint
+ - uses: actions/setup-go@v3
+ with:
+ go-version: 1.21
+ check-latest: true
+ - uses: actions/checkout@v3
+ - uses: golangci/golangci-lint-action@v3.3.1
+ with:
+ # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
+ version: latest
+ args: --timeout 10m
+ github-token: ${{ secrets.github_token }}
diff --git a/.gitea/workflows/proto.yml b/.gitea/workflows/proto.yml
new file mode 100644
index 00000000..49670ac2
--- /dev/null
+++ b/.gitea/workflows/proto.yml
@@ -0,0 +1,29 @@
+name: Protobuf
+# Protobuf runs buf (https://buf.build/) lint and check-breakage
+# This workflow is only run when a .proto file has been changed
+on:
+ pull_request:
+ paths:
+ - "proto/**"
+
+jobs:
+ lint:
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ steps:
+ - uses: actions/checkout@v3
+ - uses: bufbuild/buf-setup-action@v1.9.0
+ - uses: bufbuild/buf-lint-action@v1
+ with:
+ input: "proto"
+
+ # TODO: Update with gitea reference
+ # break-check:
+ # runs-on: ubuntu-latest
+ # steps:
+ # - uses: actions/checkout@v3
+ # - uses: bufbuild/buf-setup-action@v1.9.0
+ # - uses: bufbuild/buf-breaking-action@v1
+ # with:
+ # input: "proto"
+ # against: "https://github.com/${{ github.repository }}.git#branch=${{ github.event.pull_request.base.ref }},ref=HEAD~1,subdir=proto"
diff --git a/.gitea/workflows/test-unit.yml b/.gitea/workflows/test-unit.yml
new file mode 100644
index 00000000..fc04eadb
--- /dev/null
+++ b/.gitea/workflows/test-unit.yml
@@ -0,0 +1,19 @@
+name: Unit Tests
+on:
+ pull_request:
+ push:
+ branches:
+ - main
+
+jobs:
+ test-unit:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/setup-go@v3
+ with:
+ go-version: 1.21
+ check-latest: true
+ - uses: actions/checkout@v3
+ - name: Test
+ run: |
+ make test-unit
diff --git a/Makefile b/Makefile
index a89331a3..c387948a 100644
--- a/Makefile
+++ b/Makefile
@@ -103,3 +103,6 @@ test-integration:
test-e2e:
$(MAKE) -C tests test-e2e
+
+test-unit:
+ go test ./utils/... ./cmd/... -mod=readonly -test.v
diff --git a/README.md b/README.md
index 73266c19..390bde33 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,12 @@
-# laconic2d
+
+
Laconic Network
+
+
+![banner](docs/laconic.jpeg)
+
+The Source of Proof. Laconic is a next generation data availability & verifiability layer with cryptographic proofs, powering internet-scale Web3 applications, built on Proof-of-Stake with fast-finality using the [Cosmos SDK](https://github.com/cosmos/cosmos-sdk/) which runs on top of [CometBFT](https://github.com/cometbft/cometbft) consensus engine.
+
+## Installation
Install `laconic2d`:
@@ -7,6 +15,8 @@ Install `laconic2d`:
make install
```
+## Usage
+
Run with a single node fixture:
```bash
@@ -17,6 +27,8 @@ Run with a single node fixture:
./scripts/init.sh clean
```
+## Tests
+
Run tests:
```bash
diff --git a/app/export.go b/app/export.go
index 81178cc9..cd119a3e 100644
--- a/app/export.go
+++ b/app/export.go
@@ -73,7 +73,7 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
/* Handle fee distribution state. */
// withdraw all validator commission
- app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
+ _ = app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())
if err != nil {
panic(err)
@@ -114,7 +114,7 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
ctx = ctx.WithBlockHeight(0)
// reinitialize all validators
- app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
+ _ = app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
valBz, err := app.StakingKeeper.ValidatorAddressCodec().StringToBytes(val.GetOperator())
if err != nil {
panic(err)
@@ -171,20 +171,20 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
/* Handle staking state. */
// iterate through redelegations, reset creation height
- app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
+ _ = app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) {
for i := range red.Entries {
red.Entries[i].CreationHeight = 0
}
- app.StakingKeeper.SetRedelegation(ctx, red)
+ _ = app.StakingKeeper.SetRedelegation(ctx, red)
return false
})
// iterate through unbonding delegations, reset creation height
- app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
+ _ = app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) {
for i := range ubd.Entries {
ubd.Entries[i].CreationHeight = 0
}
- app.StakingKeeper.SetUnbondingDelegation(ctx, ubd)
+ _ = app.StakingKeeper.SetUnbondingDelegation(ctx, ubd)
return false
})
@@ -208,7 +208,7 @@ func (app *LaconicApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr
validator.Jailed = true
}
- app.StakingKeeper.SetValidator(ctx, validator)
+ _ = app.StakingKeeper.SetValidator(ctx, validator)
counter++
}
diff --git a/cmd/laconic2d/cmd_test.go b/cmd/laconic2d/cmd_test.go
new file mode 100644
index 00000000..dc9ecd5a
--- /dev/null
+++ b/cmd/laconic2d/cmd_test.go
@@ -0,0 +1,28 @@
+package main_test
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+
+ "github.com/cosmos/cosmos-sdk/client/flags"
+ svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
+ "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
+
+ "git.vdb.to/cerc-io/laconic2d/app"
+ "git.vdb.to/cerc-io/laconic2d/cmd/laconic2d/cmd"
+)
+
+func TestInitCmd(t *testing.T) {
+ rootCmd := cmd.NewRootCmd()
+ rootCmd.SetArgs([]string{
+ "init", // Test the init cmd
+ "localtestnet", // Moniker
+ fmt.Sprintf("--%s=%s", cli.FlagOverwrite, "true"), // Overwrite genesis.json, in case it already exists
+ fmt.Sprintf("--%s=%s", flags.FlagChainID, "laconic_9000-1"),
+ })
+
+ err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome)
+ require.NoError(t, err)
+}
diff --git a/docs/laconic.jpeg b/docs/laconic.jpeg
new file mode 100644
index 00000000..9ffe404e
Binary files /dev/null and b/docs/laconic.jpeg differ
diff --git a/gql/resolver.go b/gql/resolver.go
index 1e7fab7a..ca300885 100644
--- a/gql/resolver.go
+++ b/gql/resolver.go
@@ -6,6 +6,7 @@ import (
"strconv"
"github.com/cosmos/cosmos-sdk/client"
+ types "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
@@ -216,7 +217,7 @@ func (q queryResolver) GetAccount(ctx context.Context, address string) (*Account
if err != nil {
return nil, err
}
- var account authtypes.AccountI
+ var account types.AccountI
err = q.ctx.Codec.UnpackAny(accountResponse.GetAccount(), &account)
if err != nil {
return nil, err
diff --git a/tests/e2e/auction/suite.go b/tests/e2e/auction/suite.go
index ce322258..717ed1e1 100644
--- a/tests/e2e/auction/suite.go
+++ b/tests/e2e/auction/suite.go
@@ -130,19 +130,16 @@ func (ets *E2ETestSuite) createAuctionAndBid(createAuction, createBid bool) stri
return auctionId
}
-func (ets *E2ETestSuite) cleanupBidFiles() error {
+func (ets *E2ETestSuite) cleanupBidFiles() {
matches, err := filepath.Glob(fmt.Sprintf("%s-*.json", bidderAccount))
if err != nil {
ets.T().Errorf("Error matching bidder files: %v\n", err)
- return err
}
for _, match := range matches {
err := os.Remove(match)
if err != nil {
- return err
+ ets.T().Errorf("Error removing bidder file: %v\n", err)
}
}
-
- return nil
}
diff --git a/tests/integration/registry/keeper/common_test.go b/tests/integration/registry/keeper/common_test.go
index 05712894..0dba8fe6 100644
--- a/tests/integration/registry/keeper/common_test.go
+++ b/tests/integration/registry/keeper/common_test.go
@@ -25,10 +25,11 @@ type KeeperTestSuite struct {
}
func (kts *KeeperTestSuite) SetupTest() {
- kts.TestFixture.Setup()
+ err := kts.TestFixture.Setup()
+ assert.Nil(kts.T(), err)
// set default params
- err := kts.RegistryKeeper.Params.Set(kts.SdkCtx, types.DefaultParams())
+ err = kts.RegistryKeeper.Params.Set(kts.SdkCtx, types.DefaultParams())
assert.Nil(kts.T(), err)
qr := kts.App.QueryHelper()
diff --git a/utils/json_test.go b/utils/json_test.go
new file mode 100644
index 00000000..921a7f05
--- /dev/null
+++ b/utils/json_test.go
@@ -0,0 +1,33 @@
+package utils
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+func TestAndValidateCIDGeneration(t *testing.T) {
+ testCases := []struct {
+ name string
+ content string
+ expected string
+ }{
+ {
+ "empty string", "", "",
+ },
+ {
+ "empty json", "{}", "bafyreigbtj4x7ip5legnfznufuopl4sg4knzc2cof6duas4b3q2fy6swua",
+ },
+
+ {
+ "test record", "{\"build_artifact_cid\":\"QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9\",\"repo_registration_record_cid\":\"QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D\",\"tls_cert_cid\":\"QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR\",\"type\":\"WebsiteRegistrationRecord\",\"url\":\"https://cerc.io\",\"version\":\"0.0.1\"}",
+ "bafyreiek4hnoqmits66bjyxswapplweuoqe4en2ux6u772o4y3askpd3ny",
+ },
+ }
+
+ for _, tc := range testCases {
+ newImpl, err := CIDFromJSONBytes([]byte(tc.content))
+ require.NoError(t, err)
+ require.Equal(t, tc.expected, newImpl)
+ }
+}