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

Withdraw rewards ... tests #773

Merged
merged 59 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
4dea07b
first part Validator
Ebazhanov Jul 12, 2022
cf91cc4
revert change
Ebazhanov Jul 12, 2022
0a50a8e
update path
Ebazhanov Jul 12, 2022
671a0aa
next part#3
Ebazhanov Jul 13, 2022
e30b97e
final part #4
Ebazhanov Jul 13, 2022
74769a9
correction
Ebazhanov Jul 14, 2022
2174201
forgot to remove
Ebazhanov Jul 14, 2022
581d08f
first part#1
Ebazhanov Jul 14, 2022
18d99ed
clean up
Ebazhanov Jul 14, 2022
23dbfaf
an other improvements
Ebazhanov Jul 14, 2022
7063727
Merge branch 'check-validator-data-cy' into withdraw-my-rewads
Ebazhanov Jul 14, 2022
6a61be4
next part#2
Ebazhanov Jul 14, 2022
ec542d4
part#3
Ebazhanov Jul 15, 2022
b6a9816
improvements & refactoring
Ebazhanov Jul 15, 2022
be0f646
fix unstable test
Ebazhanov Jul 15, 2022
6e90a97
first part
Ebazhanov Jul 15, 2022
6c41a3b
part#2
Ebazhanov Jul 15, 2022
e529cf0
part#3
Ebazhanov Jul 16, 2022
245c343
Merge remote-tracking branch 'origin/main' into withdraw-my-rewads
Ebazhanov Aug 8, 2022
a436067
fix merge conflicts
Ebazhanov Aug 8, 2022
ad513c1
some fixes
Ebazhanov Aug 8, 2022
f8890c9
Merge remote-tracking branch 'origin/main' into withdraw-rewards-to-a…
Ebazhanov Aug 8, 2022
1eac213
Merge branch 'withdraw-my-rewads' into withdraw-rewards-to-an-other-a…
Ebazhanov Aug 8, 2022
74c692b
replacement with internal functions
Ebazhanov Aug 8, 2022
891700c
next part of improvements
Ebazhanov Aug 8, 2022
d41a705
finish test c02
Ebazhanov Aug 9, 2022
8fdc02d
[c03] first part
Ebazhanov Aug 10, 2022
97838f0
[c03] final part
Ebazhanov Aug 11, 2022
ae0a2d0
refactoring + started with [c04]
Ebazhanov Aug 12, 2022
7dff6e4
refactoring
Ebazhanov Aug 12, 2022
03d6dc7
refactoring part#2
Ebazhanov Aug 12, 2022
09ef42d
improvements
Ebazhanov Aug 15, 2022
a28938e
have finished [c04]
Ebazhanov Aug 15, 2022
986aefa
refactoring #3
Ebazhanov Aug 15, 2022
d31e11c
refactoring #4
Ebazhanov Aug 16, 2022
953dab0
refactoring #5
Ebazhanov Aug 16, 2022
977e55c
make assertion more flexible
Ebazhanov Aug 16, 2022
7ceadce
Merge remote-tracking branch 'origin/main' into withdraw-rewards-to-a…
Ebazhanov Aug 17, 2022
fc6bcc8
implement [a01]
Ebazhanov Aug 17, 2022
370234c
first part [d03]
Ebazhanov Aug 17, 2022
39e12b5
finish [d03]
Ebazhanov Aug 17, 2022
9189233
additional for [d03]
Ebazhanov Aug 18, 2022
cdce77f
finish [d04]
Ebazhanov Aug 18, 2022
13d659f
first part [d05]
Ebazhanov Aug 22, 2022
a004470
fix [c03]
Ebazhanov Aug 23, 2022
4d11606
rearrange [c04]
Ebazhanov Aug 24, 2022
5a5d5fa
Merge remote-tracking branch 'origin/main' into withdraw-rewards-to-a…
Ebazhanov Aug 24, 2022
7255a86
next improvements [c04]
Ebazhanov Aug 24, 2022
7666703
finalise [d05]
Ebazhanov Aug 24, 2022
46b708c
fix failed test
Ebazhanov Aug 24, 2022
d27f83c
fix unstable test
Ebazhanov Aug 24, 2022
afc9950
clean up, fix unstable tests
Ebazhanov Aug 25, 2022
d05b6da
next attempt to wait for transaction
Ebazhanov Aug 25, 2022
2f4bc36
trying to fix failed test
Ebazhanov Aug 25, 2022
a54d897
add steps for [c03]
Ebazhanov Aug 25, 2022
c49d7fa
revert prev commit [c03], upd names
Ebazhanov Aug 25, 2022
1e42a5c
remove `my` word
Ebazhanov Aug 25, 2022
d3b6aeb
finish [d06]
Ebazhanov Aug 25, 2022
87e3c98
correction [d06]
Ebazhanov Aug 25, 2022
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
7 changes: 0 additions & 7 deletions cypress/features/[e2e-a01]tgdBalance.feature

This file was deleted.

4 changes: 2 additions & 2 deletions cypress/features/[e2e-a02]cw20Balance.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: See my CW20 tokens that I have pinned and have non zero balance
Background:
* I connect to Web Demo wallet
* I visit T-Market
* I connect Web Demo wallet
* I visit T-Market page
* I create a CW20 token called CWA
* I click on my address on the side menu

Expand Down
13 changes: 0 additions & 13 deletions cypress/features/[e2e-c01]withdrawMyRewards.feature

This file was deleted.

14 changes: 0 additions & 14 deletions cypress/features/[e2e-c02]withdrawMyRewardsToAnother.feature

This file was deleted.

31 changes: 0 additions & 31 deletions cypress/features/[e2e-c03]withdrawRewardsAsDelegate.feature

This file was deleted.

This file was deleted.

15 changes: 0 additions & 15 deletions cypress/features/[e2e-d03]stakeTokens.feature

This file was deleted.

15 changes: 0 additions & 15 deletions cypress/features/[e2e-d04]unstakeTokens.feature

This file was deleted.

15 changes: 0 additions & 15 deletions cypress/features/[e2e-d05]valWithdrawMyRewards.feature

This file was deleted.

16 changes: 0 additions & 16 deletions cypress/features/[e2e-d06]valWithdrawMyRewardsToAnother.feature

This file was deleted.

84 changes: 84 additions & 0 deletions cypress/fixtures/existingAccounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
enum Mnemonics {
node0Mnemonic = "fox orange tiger coach ski arm shrimp scrub quote reason visa better wait drift program burst mind assault develop canvas inspire battle odor visit",
node1Mnemonic = "merit daring radio hospital exchange kitten skirt cry seven evil faculty lion cup inherit live host stable tuna convince tip blur sphere curve search",
firstMnemonic = "move drastic law sustain decade parent stairs minor cry help worry minute bridge bone force found mimic frown burst foil avocado water kingdom picture",
secondMnemonic = "cancel fault concert check match goose auto item judge couch exist shop mango option sister edit maze wide praise tortoise memory right post unusual",
thirdMnemonic = "pink neutral tray meadow pet caught cereal pass test swarm edge junior cradle all split matrix siege squeeze hobby fence act human patrol ramp",
fourthMnemonic = "shell display fetch burst pear naive hip box nose gallery unlock sign surprise ancient elite girl winter disorder wish list maximum galaxy twenty rather",
fifthMnemonic = "enroll collect warm liar allow symbol topic reveal forget cute layer lens crucial wheat remind unknown barrel piece horror depend quarter position adjust clog",
sixthMnemonic = "wink trophy quit belt rely corn style cupboard mix price abstract sentence joy column half woman thank firm mushroom lamp into hockey diary inside",
}

enum ExistingAddresses {
adminAccount = "tgrade1kalzk5cvq5yu6f5u73k7r905yw52sawckddsc3",
node0Account = "tgrade1tsg4wldpwyehhkqx3za78ygkzatncxxup96k7h",
node1Account = "tgrade12ty7w05kswvuvvzzdxdv8w4tf7g6y9xexy5rzj",
firstAccount = "tgrade10jdqrtm46xsxtdmuyt2zfcrhupvycrpv80r7nh",
secondAccount = "tgrade1aw7g4pxlzmj85fwhd3zs5hhgs0a9xeqg28z8jl",
thirdAccount = "tgrade1dzav7m7r42sg02sqdvqelazsg0mu5ef0qjpq5e",
fourthAccount = "tgrade1kjeuxlg02ku900mzddhrvpc2cjgaaen90czgg8",
fifthAccount = "tgrade1kwh2efsmue7pms3930gsclr224k8c7uwke5jvd",
sixthAccount = "tgrade1vl76n4q0pfk2ek07tz2cd5vnlvkuf5tnznqed5",
}

enum ValidatorName {
node0Account = "moniker-0",
node1Account = "delme",
}

export const selectValidatorNameByAddressNumber = (accountNumber: string): string => {
switch (accountNumber) {
case "node0Account":
return ValidatorName.node0Account;
case "node1Account":
return ValidatorName.node1Account;
default:
return "no address number was provided";
}
};

export const selectWalletAddressByNumber = (walletNumber: string): string => {
switch (walletNumber) {
case "node0Account":
return ExistingAddresses.node0Account;
case "node1Account":
return ExistingAddresses.node1Account;
case "firstAccount":
return ExistingAddresses.firstAccount;
case "secondAccount":
return ExistingAddresses.secondAccount;
case "thirdAccount":
return ExistingAddresses.thirdAccount;
case "fourthAccount":
return ExistingAddresses.fourthAccount;
case "fifthAccount":
return ExistingAddresses.fifthAccount;
case "sixthAccount":
return ExistingAddresses.sixthAccount;
default:
return "no wallet number was provided";
}
};

export const selectMnemonicByNumber = (mnemonicAddress: string): string => {
switch (mnemonicAddress) {
case "node0Mnemonic":
return Mnemonics.node0Mnemonic;
case "node1Mnemonic":
return Mnemonics.node1Mnemonic;
case "firstMnemonic":
return Mnemonics.firstMnemonic;
case "secondMnemonic":
return Mnemonics.secondMnemonic;
case "thirdMnemonic":
return Mnemonics.thirdMnemonic;
case "fourthMnemonic":
return Mnemonics.fourthMnemonic;
case "fifthMnemonic":
return Mnemonics.fifthMnemonic;
case "sixthMnemonic":
return Mnemonics.sixthMnemonic;
default:
return "no mnemonic was provided";
}
};
60 changes: 60 additions & 0 deletions cypress/fixtures/randomGeneratedAccount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { Bip39, Random } from "@cosmjs/crypto";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very useful file, like existingAccounts.ts. I think it would be more readable to use numbers instead of string ordinals randomMnemonicFourth -> randomMnemonic04, but I don't mind you doing it this way if you prefer it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, let me update it

import { Bech32 } from "@cosmjs/encoding";

const generateMnemonic = (): string => Bip39.encode(Random.getBytes(16)).toString();

function makeRandomTgradeAddress(): string {
return Bech32.encode("tgrade", Random.getBytes(20));
}

const randomMnemonic01 = generateMnemonic();
const randomMnemonic02 = generateMnemonic();
const randomMnemonic03 = generateMnemonic();
const randomMnemonic04 = generateMnemonic();
const randomMnemonic05 = generateMnemonic();
const randomMnemonic06 = generateMnemonic();

const randomAddress01 = makeRandomTgradeAddress();
const randomAddress02 = makeRandomTgradeAddress();
const randomAddress03 = makeRandomTgradeAddress();
const randomAddress04 = makeRandomTgradeAddress();
const randomAddress05 = makeRandomTgradeAddress();
const randomAddress06 = makeRandomTgradeAddress();

export const selectRandomGeneratedMnemonicByNumber = (addressMnemonic: string): string => {
switch (addressMnemonic) {
case "randomMnemonic01":
return randomMnemonic01;
case "randomMnemonic02":
return randomMnemonic02;
case "randomMnemonic03":
return randomMnemonic03;
case "randomMnemonic04":
return randomMnemonic04;
case "randomMnemonic05":
return randomMnemonic05;
case "randomMnemonic06":
return randomMnemonic06;
default:
return "no mnemonic was provided";
}
};

export const selectRandomGeneratedAddressByNumber = (number: string): string => {
switch (number) {
case "randomAddress01":
return randomAddress01;
case "randomAddress02":
return randomAddress02;
case "randomAddress03":
return randomAddress03;
case "randomAddress04":
return randomAddress04;
case "randomAddress05":
return randomAddress05;
case "randomAddress06":
return randomAddress06;
default:
return "no number was provided";
}
};
7 changes: 7 additions & 0 deletions cypress/integration/[a01]-tgdBalance.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Feature: See my Tgrade token balance
Background:
* I connect Web Demo wallet
* Open wallet dialog from main menu

Scenario: Check TGD balance
* I see TGD balance "10" for random address
24 changes: 24 additions & 0 deletions cypress/integration/[c01]-withdrawMyRewards.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Feature: Withdraw my rewards to my address
Background:
* I connect Web Demo wallet
* Set existing "firstMnemonic" wallet with Engagement Points and Engagement Rewards
* Open wallet dialog from main menu
* I see my TGD balance in wallet "firstMnemonic"
* I close wallet dialog modal
* I visit Engagement page

Scenario: Withdraw rewards

# Check balance of initial address before
* I see the "Address" field prefilled with my "firstAccount" wallet
* I see Engagement Points "5 / 2034 (0.25%)" and Engagement Rewards "9" TGD

# Withdraw rewards
* I click on the "Withdraw rewards" button
* I see Tx success screen with existing "firstAccount" address
* I click Go to Engagement button

# Check balance of initial address after
* I see Engagement Points "5 / 2034 (0.25%)" and Engagement Rewards "0" TGD
* Open wallet dialog from main menu
* I see that TGD balance "1009" has gone up for "firstAccount" address
27 changes: 27 additions & 0 deletions cypress/integration/[c02]-withdrawMyRewardsToAnother.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Feature: Withdraw my rewards to another address
Background:
* I connect Web Demo wallet
* Set existing "secondMnemonic" wallet with Engagement Points and Engagement Rewards
* Open wallet dialog from main menu
* I see my TGD balance in wallet "secondMnemonic"
* I close wallet dialog modal
* I visit Engagement page

Scenario: Withdraw rewards using "Receiver address"

# Check balance of initial address before
* I see the "Address" field prefilled with my "secondAccount" wallet
* I see Engagement Points "7 / 2034 (0.34%)" and Engagement Rewards "14" TGD

# Set receiver address
* I enter address in the "Receiver address" field from "randomMnemonic01" wallet
* I use "randomMnemonic01" to make query and check balance of this address "0"

# Withdraw rewards
* I click on the "Withdraw rewards" button
* I see Tx success screen with address from "randomMnemonic01"
* I click Go to Engagement button
* I see Engagement Points "7 / 2034 (0.34%)" and Engagement Rewards "0" TGD

# Check receiver address balance
* I use "randomMnemonic01" to make query and check balance of this address "14"
Loading