Skip to content

Commit

Permalink
Merge branch 'fix/module-claims' into fix_thor_mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyasbhat0 committed Oct 17, 2024
2 parents 715ea96 + ef3f861 commit 002ddc3
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .goreleaser-cross.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ archives:
- none*

checksum:
name_template: '{{ .ProjectName }}d_v{{ .Version }}_{{ if eq .Env.BUILD_TAG "testnet" }}_testnet{{ end }}_cross_checksums.txt'
name_template: '{{ .ProjectName }}d_v{{ .Version }}_{{ if eq .Env.BUILD_TAG "testnet" }}testnet{{ end }}_cross_checksums.txt'

dockers:
- use: buildx
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ archives:
files:
- none*
checksum:
name_template: '{{ .ProjectName }}d_v{{ .Version }}_{{ if eq .Env.BUILD_TAG "testnet" }}_testnet{{ end }}_checksums.txt'
name_template: '{{ .ProjectName }}d_v{{ .Version }}_{{ if eq .Env.BUILD_TAG "testnet" }}testnet{{ end }}_checksums.txt'
dockers:
- use: buildx
goos: linux
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ Contains bug fixes.
Contains all the PRs that improved the code without changing the behaviors.
-->

# v1.0.2-Prerelease

## Added

## Changed
- Updated thorchain claim server address handling

## Fixed
- Fixed Regression Test Version Issues

# v1.0.1-Prerelease

## Added
Expand Down
1 change: 1 addition & 0 deletions test/regression/cmd/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func export(path string) error {
appState, _ := export["app_state"].(map[string]any)
claimArkeo, _ := appState["claimarkeo"].(map[string]any)
params, _ := claimArkeo["params"].(map[string]any)
delete(export, "app_version")
delete(params, "airdrop_start_time")
staking, _ := appState["staking"].(map[string]any)
validators, _ := staking["validators"].([]any)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,6 @@
"upgrade": {},
"vesting": {}
},
"app_version": "v1.0.0-prerelease",
"chain_id": "arkeo",
"consensus": {
"params": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,6 @@
"upgrade": {},
"vesting": {}
},
"app_version": "v1.0.0-prerelease",
"chain_id": "arkeo",
"consensus": {
"params": {
Expand Down
1 change: 0 additions & 1 deletion test/regression/mnt/exports/suites_core_send.json
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@
"upgrade": {},
"vesting": {}
},
"app_version": "v1.0.0-prerelease",
"chain_id": "arkeo",
"consensus": {
"params": {
Expand Down
1 change: 0 additions & 1 deletion test/regression/mnt/exports/suites_initialize.json
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,6 @@
"upgrade": {},
"vesting": {}
},
"app_version": "v1.0.0-prerelease",
"chain_id": "arkeo",
"consensus": {
"params": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,6 @@
"upgrade": {},
"vesting": {}
},
"app_version": "v1.0.0-prerelease",
"chain_id": "arkeo",
"consensus": {
"params": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,6 @@
"upgrade": {},
"vesting": {}
},
"app_version": "v1.0.0-prerelease",
"chain_id": "arkeo",
"consensus": {
"params": {
Expand Down
1 change: 0 additions & 1 deletion test/regression/mnt/exports/suites_sentinel_sentinel.json
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,6 @@
"upgrade": {},
"vesting": {}
},
"app_version": "v1.0.0-prerelease",
"chain_id": "arkeo",
"consensus": {
"params": {
Expand Down
74 changes: 73 additions & 1 deletion x/claim/keeper/msg_server_claim_thorchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/arkeonetwork/arkeo/x/claim/types"
)

func TestClaimThorchain(t *testing.T) {
func TestClaimThorchainTestnetAddress(t *testing.T) {
msgServer, keepers, ctx := setupMsgServer(t)
sdkCtx := sdk.UnwrapSDKContext(ctx)

Expand Down Expand Up @@ -81,3 +81,75 @@ func TestClaimThorchain(t *testing.T) {
_, err = msgServer.ClaimThorchain(ctx, &claimMessage)
require.ErrorIs(t, err, types.ErrNoClaimableAmount)
}

func TestClaimThorchainMainnetAddress(t *testing.T) {
msgServer, keepers, ctx := setupMsgServer(t)
sdkCtx := sdk.UnwrapSDKContext(ctx)

config := sdk.GetConfig()
config.SetBech32PrefixForAccount("arkeo", "arkeopub")

arkeoServerAddress, err := sdk.AccAddressFromBech32("arkeo1z02ke8639m47g9dfrheegr2u9zecegt50fjg7v")
require.NoError(t, err)

fromAddr := utils.GetRandomArkeoAddress()
toAddr := utils.GetRandomArkeoAddress()

claimRecordFrom := types.ClaimRecord{
Chain: types.ARKEO,
Address: fromAddr.String(),
AmountClaim: sdk.NewInt64Coin(types.DefaultClaimDenom, 100),
AmountVote: sdk.NewInt64Coin(types.DefaultClaimDenom, 100),
AmountDelegate: sdk.NewInt64Coin(types.DefaultClaimDenom, 100),
}
claimRecordTo := types.ClaimRecord{
Chain: types.ARKEO,
Address: toAddr.String(),
AmountClaim: sdk.NewInt64Coin(types.DefaultClaimDenom, 100),
AmountVote: sdk.NewInt64Coin(types.DefaultClaimDenom, 100),
AmountDelegate: sdk.NewInt64Coin(types.DefaultClaimDenom, 100),
}
err = keepers.ClaimKeeper.SetClaimRecord(sdkCtx, claimRecordFrom)
require.NoError(t, err)
err = keepers.ClaimKeeper.SetClaimRecord(sdkCtx, claimRecordTo)
require.NoError(t, err)

// mint coins to module account
err = keepers.BankKeeper.MintCoins(sdkCtx, types.ModuleName, sdk.NewCoins(sdk.NewInt64Coin(types.DefaultClaimDenom, 10000)))
require.NoError(t, err)

invalidClaimMessage := types.MsgClaimThorchain{
Creator: fromAddr.String(),
FromAddress: fromAddr.String(),
ToAddress: toAddr.String(),
}
_, err = msgServer.ClaimThorchain(ctx, &invalidClaimMessage)
require.ErrorIs(t, types.ErrInvalidCreator, err)

claimMessage := types.MsgClaimThorchain{
Creator: arkeoServerAddress.String(),
FromAddress: fromAddr.String(),
ToAddress: toAddr.String(),
}
_, err = msgServer.ClaimThorchain(ctx, &claimMessage)
require.NoError(t, err)

// check if claimrecord is updated
claimRecordFrom, err = keepers.ClaimKeeper.GetClaimRecord(sdkCtx, fromAddr.String(), types.ARKEO)
require.NoError(t, err)
require.True(t, claimRecordFrom.IsEmpty())

claimRecordTo, err = keepers.ClaimKeeper.GetClaimRecord(sdkCtx, toAddr.String(), types.ARKEO)
require.NoError(t, err)
require.True(t, !claimRecordTo.IsEmpty())

require.Equal(t, claimRecordTo.Address, toAddr.String())
require.Equal(t, claimRecordTo.Chain, types.ARKEO)
require.Equal(t, claimRecordTo.AmountClaim, sdk.NewInt64Coin(types.DefaultClaimDenom, 200))
require.Equal(t, claimRecordTo.AmountVote, sdk.NewInt64Coin(types.DefaultClaimDenom, 200))
require.Equal(t, claimRecordTo.AmountDelegate, sdk.NewInt64Coin(types.DefaultClaimDenom, 200))

// attempt to claim again to ensure it fails.
_, err = msgServer.ClaimThorchain(ctx, &claimMessage)
require.ErrorIs(t, err, types.ErrNoClaimableAmount)
}

0 comments on commit 002ddc3

Please sign in to comment.