Skip to content
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

Danwt/aider 0 #1566

Closed
wants to merge 6 commits into from
Closed
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ build/
proposal.json
.go-version
**/testdata/rapid/
**/__debug_bin*
**/__debug_bin*
.aider*
.env
91 changes: 79 additions & 12 deletions x/common/types/key_rollapp_packet_test.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,101 @@
package types_test

import (
"encoding/hex"
"fmt"
"strings"
"testing"

transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
eibctypes "github.com/dymensionxyz/dymension/v3/x/eibc/types"
"github.com/stretchr/testify/require"

"github.com/dymensionxyz/dymension/v3/x/common/types"
commontypes "github.com/dymensionxyz/dymension/v3/x/common/types"
)

func TestEncodeDecodePacketKey(t *testing.T) {
packet := commontypes.RollappPacket{
RollappId: "rollapp_1234-1",
Status: commontypes.Status_PENDING,
ProofHeight: 8,
Packet: getNewTestPacket(t),
type tcase struct {
orderID string
tracker string
bz []byte
}

func TestFooKey(t *testing.T) {

var testcases = []tcase{
{
orderID: "8c2bfdcb05c9f9519ffb08eff4d517e4c6a2c69f1b6c0bd7c508d2f76218d4e1",
tracker: `/mande_18071918-1/d�/ON_RECV/channel-0/��`,
bz: commontypes.RollappPacketKey(
commontypes.Status_PENDING,
"mande_18071918-1",
1205408,
commontypes.RollappPacket_ON_RECV,
"channel-0",
53449,
),
},
{
orderID: "2ab7c88129c2c5a5b401a43e8423b2eab3ed3e2cf67dc71df8a88e97336b97b7",
tracker: `/mande_18071918-1/k�/ON_RECV/channel-0/��`,
bz: commontypes.RollappPacketKey(
commontypes.Status_PENDING,
"mande_18071918-1",
1207252,
commontypes.RollappPacket_ON_RECV,
"channel-0",
53450,
),
},
{
orderID: "c9c834d23707fa53a55944c98c767e319f51ff610fdbb866b8f7d35088ef543f",
tracker: `/mande_18071918-1/o/ON_RECV/channel-0/��`,
bz: commontypes.RollappPacketKey(
commontypes.Status_PENDING,
"mande_18071918-1",
1208081,
commontypes.RollappPacket_ON_RECV,
"channel-0",
53451,
),
},
}

expectedPK := packet.RollappPacketKey()
for _, tc := range testcases {
idGotRebuild := eibctypes.BuildDemandIDFromPacketKey(string(tc.bz))
idGotTracker := eibctypes.BuildDemandIDFromPacketKey(string(tc.tracker))

Check failure on line 66 in x/common/types/key_rollapp_packet_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

unnecessary conversion (unconvert)
k := string(tc.bz)
fmt.Println(tc.orderID, "key", len(k), k)

encoded := types.EncodePacketKey(expectedPK)
decoded, err := types.DecodePacketKey(encoded)
require.NoError(t, err)
t.Log(fmt.Sprintf(`

Check failure on line 70 in x/common/types/key_rollapp_packet_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

S1038: should use t.Logf(...) instead of t.Log(fmt.Sprintf(...)) (gosimple)
order id: %s,
tracker: %s,
actual : %s,
order id rebuild : %s,
order id tracker : %s,
`, tc.orderID, tc.tracker, string(tc.bz), idGotRebuild, idGotTracker))
//t.Log(tc.orderID, "Tracker: ", tc.tracker, "Actual reversed:", string(tc.bz))
}
t.FailNow()
}

func decodeTrackingPacketKey(encodedKey string) (string, error) {

Check failure on line 82 in x/common/types/key_rollapp_packet_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

func `decodeTrackingPacketKey` is unused (unused)
// Replace Unicode escape sequences with their actual characters
decodedKey := strings.ReplaceAll(encodedKey, "\\u0000", "\x00")
decodedKey = strings.ReplaceAll(decodedKey, "\\u0001", "\x01")
decodedKey = strings.ReplaceAll(decodedKey, "\\u0012", "\x12")
// Add more replacements as needed

// Decode any remaining hex-encoded characters
decodedBytes, err := hex.DecodeString(decodedKey)
if err != nil {
return "", err
}

require.Equal(t, expectedPK, decoded)
return string(decodedBytes), nil
}

func getNewTestPacket(t *testing.T) *channeltypes.Packet {

Check failure on line 98 in x/common/types/key_rollapp_packet_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

func `getNewTestPacket` is unused (unused)
t.Helper()
data := &transfertypes.FungibleTokenPacketData{
Receiver: "testReceiver",
Expand Down
41 changes: 41 additions & 0 deletions x/delayedack/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
@@ -1 +1,42 @@
package keeper

import (
"testing"

commontypes "github.com/dymensionxyz/dymension/v3/x/common/types"
)

func TestFoo(t *testing.T) {
/*
ProofHeight: "1205408"
acknowledgement: null
error: ""
original_transfer_target: dym1gurgw3tkfpl8nvt9ypqhtccr3t5elere7aq3x6
packet:
data: eyJhbW91bnQiOiIyMTQzMDAwMDAwMDAwMDAwMDAwMDAwIiwiZGVub20iOiJhbWFuZCIsIm1lbW8iOiJ7XCJlaWJjXCI6e1wiZmVlXCI6XCIzMjE0NTAwMDAwMDAwMDAwMDAwXCJ9fSIsInJlY2VpdmVyIjoiZHltMWZubXJxdTh0aHdxanNtZ2xtd2pweWY4M2N4eWp0a3Z5MHNkNTk3Iiwic2VuZGVyIjoibWFuZGUxdjdhN216eXh6eTZwd2puaGxnMHZkaGdwa2w0OG14MnZ6M2FzcHMifQ==
destination_channel: channel-51
destination_port: transfer
sequence: "53449"
source_channel: channel-0
source_port: transfer
timeout_height:
revision_height: "1"
revision_number: "9999"
timeout_timestamp: "1730182200000000000"
relayer: iO9Wcqyjk5AUJ3oecGw+0bTXAiU=
rollapp_id: mande_18071918-1
status: PENDING
type: ON_RECV
*/

x := commontypes.RollappPacketKey(
commontypes.Status_PENDING,
"mande_18071918-1",
1205408,
commontypes.RollappPacket_ON_RECV,
"channel-0",
53449,
)
t.Log(commontypes.EncodePacketKey(x))

}
1 change: 1 addition & 0 deletions x/eibc/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command {

cmd.AddCommand(CmdQueryParams())
cmd.AddCommand(CmdListDemandOrdersByStatus())
cmd.AddCommand(CmdDemandOrderByID())
// this line is used by starport scaffolding # 1

return cmd
Expand Down
27 changes: 27 additions & 0 deletions x/eibc/client/cli/query_command_orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@ import (
"github.com/dymensionxyz/dymension/v3/x/eibc/types"
)

func CmdDemandOrderByID() *cobra.Command {
cmd := &cobra.Command{
Use: "get-demand-order [id]",
Short: "Get by id",
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
request := &types.QueryGetDemandOrderRequest{
Id: args[0],
}
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.DemandOrderById(cmd.Context(), request)
if err != nil {
return err
}
k := res.DemandOrder.TrackingPacketKey
fmt.Println("key", len(k), res.DemandOrder.TrackingPacketKey)
return clientCtx.PrintProto(res)
},
}
flags.AddQueryFlagsToCmd(cmd)
return cmd
}

func CmdListDemandOrdersByStatus() *cobra.Command {
cmd := &cobra.Command{
Use: "list-demand-orders status [rollapp] [recipient] [type] [denom] [fulfilled] [fulfiller] [limit]",
Expand Down
Loading