Skip to content

Run modernizer on codebase #657

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

Merged
merged 1 commit into from
Apr 23, 2025
Merged
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
2 changes: 1 addition & 1 deletion ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type AcknowledgeDispatch struct {
Err string `json:"error"`
}

func toBytes(t *testing.T, v interface{}) []byte {
func toBytes(t *testing.T, v any) []byte {
t.Helper()
bz, err := json.Marshal(v)
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions internal/api/iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func setupQueueContractWithData(t *testing.T, cache Cache, values ...int) queueD
for _, value := range values {
// push 17
var gasMeter2 types.GasMeter = NewMockGasMeter(TESTING_GAS_LIMIT)
push := []byte(fmt.Sprintf(`{"enqueue":{"value":%d}}`, value))
push := fmt.Appendf(nil, `{"enqueue":{"value":%d}}`, value)
res, _, err = Execute(cache, checksum, env, info, push, &gasMeter2, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
require.NoError(t, err)
requireOkResponse(t, res, 0)
Expand Down Expand Up @@ -241,7 +241,7 @@ func TestQueueIteratorRaces(t *testing.T) {
var wg sync.WaitGroup
// for each batch, query each of the 3 contracts - so the contract queries get mixed together
wg.Add(numBatches * 3)
for i := 0; i < numBatches; i++ {
for range numBatches {
go func() {
reduceQuery(t, contract1, "[[17,22],[22,0]]")
wg.Done()
Expand Down
8 changes: 4 additions & 4 deletions internal/api/lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ func Benchmark100ConcurrentContractCalls(b *testing.B) {

info = MockInfoBin(b, "fred")

for i := 0; i < callCount; i++ {
for range callCount {
go func() {
defer wg.Done()
gasMeter2 := NewMockGasMeter(TESTING_GAS_LIMIT)
Expand All @@ -872,7 +872,7 @@ func Benchmark100ConcurrentContractCalls(b *testing.B) {
close(resChan)

// Now check results in the main test goroutine
for i := 0; i < callCount; i++ {
for range callCount {
require.NoError(b, <-errChan)
requireOkResponse(b, <-resChan, 0)
}
Expand Down Expand Up @@ -1084,7 +1084,7 @@ func TestDispatchSubmessage(t *testing.T) {
}
payloadBin, err := json.Marshal(payload)
require.NoError(t, err)
payloadMsg := []byte(fmt.Sprintf(`{"reflect_sub_msg":{"msgs":[%s]}}`, string(payloadBin)))
payloadMsg := fmt.Appendf(nil, `{"reflect_sub_msg":{"msgs":[%s]}}`, string(payloadBin))

gasMeter2 := NewMockGasMeter(TESTING_GAS_LIMIT)
igasMeter2 := types.GasMeter(gasMeter2)
Expand Down Expand Up @@ -1433,7 +1433,7 @@ func TestFloats(t *testing.T) {
hasher := sha256.New()
const RUNS_PER_INSTRUCTION = 150
for _, instr := range instructions {
for seed := 0; seed < RUNS_PER_INSTRUCTION; seed++ {
for seed := range RUNS_PER_INSTRUCTION {
// query some input values for the instruction
msg := fmt.Sprintf(`{"random_args_for":{"instruction":"%s","seed":%d}}`, instr, seed)
data, _, err = Query(cache, checksum, env, []byte(msg), &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
Expand Down
4 changes: 2 additions & 2 deletions lib_libwasmvm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ func TestLongPayloadDeserialization(t *testing.T) {
validPayload := make([]byte, 128*1024)
validPayloadJSON, err := json.Marshal(validPayload)
require.NoError(t, err)
resultJson := []byte(fmt.Sprintf(`{"ok":{"messages":[{"id":0,"msg":{"bank":{"send":{"to_address":"bob","amount":[{"denom":"ATOM","amount":"250"}]}}},"payload":%s,"reply_on":"never"}],"data":"8Auq","attributes":[],"events":[]}}`, validPayloadJSON))
resultJson := fmt.Appendf(nil, `{"ok":{"messages":[{"id":0,"msg":{"bank":{"send":{"to_address":"bob","amount":[{"denom":"ATOM","amount":"250"}]}}},"payload":%s,"reply_on":"never"}],"data":"8Auq","attributes":[],"events":[]}}`, validPayloadJSON)

// Test that a valid payload can be deserialized
var result types.ContractResult
Expand All @@ -425,7 +425,7 @@ func TestLongPayloadDeserialization(t *testing.T) {
invalidPayload := make([]byte, 128*1024+1)
invalidPayloadJSON, err := json.Marshal(invalidPayload)
require.NoError(t, err)
resultJson = []byte(fmt.Sprintf(`{"ok":{"messages":[{"id":0,"msg":{"bank":{"send":{"to_address":"bob","amount":[{"denom":"ATOM","amount":"250"}]}}},"payload":%s,"reply_on":"never"}],"attributes":[],"events":[]}}`, invalidPayloadJSON))
resultJson = fmt.Appendf(nil, `{"ok":{"messages":[{"id":0,"msg":{"bank":{"send":{"to_address":"bob","amount":[{"denom":"ATOM","amount":"250"}]}}},"payload":%s,"reply_on":"never"}],"attributes":[],"events":[]}}`, invalidPayloadJSON)

// Test that an invalid payload cannot be deserialized
err = DeserializeResponse(math.MaxUint64, deserCost, &gasReport, resultJson, &result)
Expand Down
2 changes: 1 addition & 1 deletion types/systemerror.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func ToSystemError(err error) *SystemError {
}

// check if an interface is nil (even if it has type info)
func isNil(i interface{}) bool {
func isNil(i any) bool {
if i == nil {
return true
}
Expand Down