Skip to content

Commit

Permalink
Format codebase using gofumpt
Browse files Browse the repository at this point in the history
gofumpt -w -l .
  • Loading branch information
webmaster128 committed May 3, 2022
1 parent 74c6704 commit 02af9ad
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 41 deletions.
6 changes: 4 additions & 2 deletions api/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,10 @@ func cNext(ref C.iterator_t, gasMeter *C.gas_meter_t, usedGas *C.uint64_t, key *

/***** GoAPI *******/

type HumanizeAddress func([]byte) (string, uint64, error)
type CanonicalizeAddress func(string) ([]byte, uint64, error)
type (
HumanizeAddress func([]byte) (string, uint64, error)
CanonicalizeAddress func(string) ([]byte, uint64, error)
)

type GoAPI struct {
HumanAddress HumanizeAddress
Expand Down
3 changes: 2 additions & 1 deletion api/iterator.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package api

import (
dbm "github.com/tendermint/tm-db"
"sync"

dbm "github.com/tendermint/tm-db"
)

// frame stores all Iterators for one contract
Expand Down
20 changes: 11 additions & 9 deletions api/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ import (
)

// Value types
type cint = C.int
type cbool = C.bool
type cusize = C.size_t
type cu8 = C.uint8_t
type cu32 = C.uint32_t
type cu64 = C.uint64_t
type ci8 = C.int8_t
type ci32 = C.int32_t
type ci64 = C.int64_t
type (
cint = C.int
cbool = C.bool
cusize = C.size_t
cu8 = C.uint8_t
cu32 = C.uint32_t
cu64 = C.uint64_t
ci8 = C.int8_t
ci32 = C.int32_t
ci64 = C.int64_t
)

// Pointers
type cu8_ptr = *C.uint8_t
Expand Down
17 changes: 10 additions & 7 deletions api/lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import (
"github.com/CosmWasm/wasmvm/types"
)

const TESTING_FEATURES = "staking,stargate,iterator"
const TESTING_PRINT_DEBUG = false
const TESTING_GAS_LIMIT = uint64(500_000_000_000) // ~0.5ms
const TESTING_MEMORY_LIMIT = 32 // MiB
const TESTING_CACHE_SIZE = 100 // MiB
const (
TESTING_FEATURES = "staking,stargate,iterator"
TESTING_PRINT_DEBUG = false
TESTING_GAS_LIMIT = uint64(500_000_000_000) // ~0.5ms
TESTING_MEMORY_LIMIT = 32 // MiB
TESTING_CACHE_SIZE = 100 // MiB
)

func TestInitAndReleaseCache(t *testing.T) {
dataDir := "/foo"
Expand Down Expand Up @@ -116,7 +118,8 @@ func TestPinErrors(t *testing.T) {
unknownChecksum := []byte{
0x72, 0x2c, 0x8c, 0x99, 0x3f, 0xd7, 0x5a, 0x76, 0x27, 0xd6, 0x9e, 0xd9, 0x41, 0x34,
0x4f, 0xe2, 0xa1, 0x42, 0x3a, 0x3e, 0x75, 0xef, 0xd3, 0xe6, 0x77, 0x8a, 0x14, 0x28,
0x84, 0x22, 0x71, 0x04}
0x84, 0x22, 0x71, 0x04,
}
err = Pin(cache, unknownChecksum)
require.ErrorContains(t, err, "No such file or directory")
}
Expand Down Expand Up @@ -921,7 +924,7 @@ func TestCustomReflectQuerier(t *testing.T) {
querier = Querier(innerQuerier)

// make a valid query to the other address
var queryMsg = QueryMsg{
queryMsg := QueryMsg{
Capitalized: &CapitalizedQuery{
Text: "small Frys :)",
},
Expand Down
3 changes: 1 addition & 2 deletions api/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ func (g *mockGasMeter) ConsumeGas(amount Gas, descriptor string) {
if g.consumed > g.limit {
panic(ErrorOutOfGas{descriptor})
}

}

/*** Mock KVStore ****/
Expand Down Expand Up @@ -446,7 +445,7 @@ func NewBankQuerier(balances map[string]types.Coins) BankQuerier {
func (q BankQuerier) Query(request *types.BankQuery) ([]byte, error) {
if request.Balance != nil {
denom := request.Balance.Denom
var coin = types.NewCoin(0, denom)
coin := types.NewCoin(0, denom)
for _, c := range q.Balances[request.Balance.Address] {
if c.Denom == denom {
coin = c
Expand Down
15 changes: 9 additions & 6 deletions cmd/demo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ package main

import (
"fmt"
wasmvm "github.com/CosmWasm/wasmvm"
"io/ioutil"
"os"

wasmvm "github.com/CosmWasm/wasmvm"
)

const SUPPORTED_FEATURES = "staking"
const PRINT_DEBUG = true
const MEMORY_LIMIT = 32 // MiB
const CACHE_SIZE = 100 // MiB
const (
SUPPORTED_FEATURES = "staking"
PRINT_DEBUG = true
MEMORY_LIMIT = 32 // MiB
CACHE_SIZE = 100 // MiB
)

// This is just a demo to ensure we can compile a static go binary
func main() {
Expand All @@ -22,7 +25,7 @@ func main() {
}
fmt.Println("Loaded!")

os.MkdirAll("tmp", 0755)
os.MkdirAll("tmp", 0o755)
vm, err := wasmvm.NewVM("tmp", SUPPORTED_FEATURES, MEMORY_LIMIT, PRINT_DEBUG, CACHE_SIZE)
if err != nil {
panic(err)
Expand Down
8 changes: 4 additions & 4 deletions ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ func TestIBCHandshake(t *testing.T) {
require.Equal(t, 1, len(res.Messages))

// check for the expected custom event
expected_events := []types.Event{types.Event{
expected_events := []types.Event{{
Type: "ibc",
Attributes: []types.EventAttribute{types.EventAttribute{
Attributes: []types.EventAttribute{{
Key: "channel",
Value: "connect",
}},
Expand Down Expand Up @@ -264,9 +264,9 @@ func TestIBCPacketDispatch(t *testing.T) {
require.Equal(t, "invalid packet: cosmwasm_std::addresses::Addr not found", ack2.Err)

// check for the expected custom event
expected_events := []types.Event{types.Event{
expected_events := []types.Event{{
Type: "ibc",
Attributes: []types.EventAttribute{types.EventAttribute{
Attributes: []types.EventAttribute{{
Key: "packet",
Value: "receive",
}},
Expand Down
19 changes: 11 additions & 8 deletions lib_test.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
package cosmwasm

import (
"io/ioutil"
"os"
"testing"

"github.com/CosmWasm/wasmvm/api"
"github.com/CosmWasm/wasmvm/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"io/ioutil"
"os"
"testing"
)

const TESTING_FEATURES = "staking,stargate,iterator"
const TESTING_PRINT_DEBUG = false
const TESTING_GAS_LIMIT = uint64(500_000_000_000) // ~0.5ms
const TESTING_MEMORY_LIMIT = 32 // MiB
const TESTING_CACHE_SIZE = 100 // MiB
const (
TESTING_FEATURES = "staking,stargate,iterator"
TESTING_PRINT_DEBUG = false
TESTING_GAS_LIMIT = uint64(500_000_000_000) // ~0.5ms
TESTING_MEMORY_LIMIT = 32 // MiB
TESTING_CACHE_SIZE = 100 // MiB
)

const HACKATOM_TEST_CONTRACT = "./api/testdata/hackatom.wasm"

Expand Down
4 changes: 2 additions & 2 deletions types/queries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package types

import (
"encoding/json"
"testing"

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

func TestDelegationWithEmptyArray(t *testing.T) {
Expand Down Expand Up @@ -111,5 +112,4 @@ func TestQueryResponseWithEmptyData(t *testing.T) {
}
})
}

}

0 comments on commit 02af9ad

Please sign in to comment.