@coinmasters/e2e-staking-suite 1.11.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,164 @@
1
+ # E2E Staking Test Suite
2
+
3
+ This test suite provides comprehensive testing for Cosmos staking operations including delegation, undelegation, and reward claiming.
4
+
5
+ ## Configuration
6
+
7
+ The test suite is fully configurable through the `TEST_CONFIG` object at the top of `src/index.ts`. You can enable/disable specific tests based on what you want to test.
8
+
9
+ ### Configuration Options
10
+
11
+ ```typescript
12
+ const TEST_CONFIG = {
13
+ // API Tests
14
+ TEST_VALIDATOR_API: true, // Test validator fetching APIs
15
+ TEST_STAKING_POSITIONS_API: true, // Test staking positions detection
16
+ TEST_DIRECT_STAKING_API: true, // Test direct staking API calls
17
+
18
+ // Transaction Tests
19
+ TEST_CLAIM_REWARDS: true, // ๐ŸŽฏ Test reward claiming (RECOMMENDED TO START)
20
+ TEST_DELEGATE: false, // Test delegation transactions
21
+ TEST_UNDELEGATE: false, // Test undelegation transactions
22
+
23
+ // Integration Tests
24
+ TEST_STAKING_INTEGRATION: true, // Test staking data integration
25
+
26
+ // Execution Mode
27
+ ACTUALLY_EXECUTE_TRANSACTIONS: false, // โš ๏ธ Set to true to actually execute transactions
28
+
29
+ // Network Selection
30
+ NETWORKS: [
31
+ 'GAIA', // Cosmos Hub - has active staking
32
+ 'OSMO', // Osmosis - has active staking
33
+ ]
34
+ };
35
+ ```
36
+
37
+ ## Common Use Cases
38
+
39
+ ### 1. ๐ŸŽฏ Reward Claiming Only (Recommended Starting Point)
40
+
41
+ ```typescript
42
+ const TEST_CONFIG = {
43
+ TEST_VALIDATOR_API: false,
44
+ TEST_STAKING_POSITIONS_API: true,
45
+ TEST_DIRECT_STAKING_API: false,
46
+ TEST_CLAIM_REWARDS: true, // Only test reward claiming
47
+ TEST_DELEGATE: false,
48
+ TEST_UNDELEGATE: false,
49
+ TEST_STAKING_INTEGRATION: true,
50
+ ACTUALLY_EXECUTE_TRANSACTIONS: true, // Actually claim rewards
51
+ NETWORKS: ['GAIA'] // Cosmos Hub only
52
+ };
53
+ ```
54
+
55
+ ### 2. ๐Ÿ“ˆ Delegation Testing
56
+
57
+ ```typescript
58
+ const TEST_CONFIG = {
59
+ TEST_VALIDATOR_API: true, // Need validators for delegation
60
+ TEST_STAKING_POSITIONS_API: true,
61
+ TEST_DIRECT_STAKING_API: false,
62
+ TEST_CLAIM_REWARDS: false,
63
+ TEST_DELEGATE: true, // Test delegation
64
+ TEST_UNDELEGATE: false,
65
+ TEST_STAKING_INTEGRATION: true,
66
+ ACTUALLY_EXECUTE_TRANSACTIONS: false, // Dry run first
67
+ NETWORKS: ['GAIA']
68
+ };
69
+ ```
70
+
71
+ ### 3. ๐Ÿ“‰ Undelegation Testing
72
+
73
+ ```typescript
74
+ const TEST_CONFIG = {
75
+ TEST_VALIDATOR_API: false,
76
+ TEST_STAKING_POSITIONS_API: true, // Need existing delegations
77
+ TEST_DIRECT_STAKING_API: false,
78
+ TEST_CLAIM_REWARDS: false,
79
+ TEST_DELEGATE: false,
80
+ TEST_UNDELEGATE: true, // Test undelegation
81
+ TEST_STAKING_INTEGRATION: true,
82
+ ACTUALLY_EXECUTE_TRANSACTIONS: false, // Dry run first
83
+ NETWORKS: ['GAIA']
84
+ };
85
+ ```
86
+
87
+ ### 4. ๐Ÿ” Full API Testing (No Transactions)
88
+
89
+ ```typescript
90
+ const TEST_CONFIG = {
91
+ TEST_VALIDATOR_API: true,
92
+ TEST_STAKING_POSITIONS_API: true,
93
+ TEST_DIRECT_STAKING_API: true,
94
+ TEST_CLAIM_REWARDS: false,
95
+ TEST_DELEGATE: false,
96
+ TEST_UNDELEGATE: false,
97
+ TEST_STAKING_INTEGRATION: true,
98
+ ACTUALLY_EXECUTE_TRANSACTIONS: false,
99
+ NETWORKS: ['GAIA', 'OSMO']
100
+ };
101
+ ```
102
+
103
+ ### 5. ๐Ÿš€ Full Transaction Testing
104
+
105
+ ```typescript
106
+ const TEST_CONFIG = {
107
+ TEST_VALIDATOR_API: true,
108
+ TEST_STAKING_POSITIONS_API: true,
109
+ TEST_DIRECT_STAKING_API: true,
110
+ TEST_CLAIM_REWARDS: true,
111
+ TEST_DELEGATE: true,
112
+ TEST_UNDELEGATE: true,
113
+ TEST_STAKING_INTEGRATION: true,
114
+ ACTUALLY_EXECUTE_TRANSACTIONS: true, // โš ๏ธ Will execute real transactions
115
+ NETWORKS: ['GAIA']
116
+ };
117
+ ```
118
+
119
+ ## Running the Tests
120
+
121
+ ```bash
122
+ # Install dependencies
123
+ npm install
124
+
125
+ # Run the test suite
126
+ bun run src/index.ts
127
+ ```
128
+
129
+ ## Safety Notes
130
+
131
+ - **ALWAYS** test with `ACTUALLY_EXECUTE_TRANSACTIONS: false` first
132
+ - **NEVER** set `ACTUALLY_EXECUTE_TRANSACTIONS: true` unless you want to execute real transactions
133
+ - Start with reward claiming as it's the safest operation
134
+ - Use small amounts for delegation/undelegation testing
135
+ - Remember that undelegation has a 21-day unbonding period on Cosmos Hub
136
+
137
+ ## Test Output
138
+
139
+ The test suite provides detailed logging with emojis for easy reading:
140
+
141
+ - ๐Ÿงช Test sections
142
+ - โœ… Successful operations
143
+ - โŒ Failed operations
144
+ - ๐ŸŽฏ Target operations
145
+ - ๐Ÿ’ฐ Balance information
146
+ - ๐Ÿ“Š Statistics
147
+ - ๐Ÿ”จ Transaction building
148
+ - ๐Ÿš€ Transaction execution
149
+ - โญ๏ธ Skipped tests
150
+
151
+ ## Troubleshooting
152
+
153
+ 1. **No staking positions found**: Make sure you have existing delegations or rewards
154
+ 2. **Validator API errors**: Check network connectivity and API availability
155
+ 3. **Transaction building errors**: Verify you have sufficient balance and valid validator addresses
156
+ 4. **KeepKey connection issues**: Ensure your KeepKey is connected and unlocked
157
+
158
+ ## Next Steps
159
+
160
+ After successful testing, you can integrate the staking functionality into your application using the same transaction builders:
161
+
162
+ - `app.buildDelegateTx(caip, params)`
163
+ - `app.buildUndelegateTx(caip, params)`
164
+ - `app.buildClaimRewardsTx(caip, params)`