Skip to content

Commit 4def75d

Browse files
justin j. mosesjjgonecrypto
justin j. moses
authored andcommitted
Fixing broken tests from staking reward checks (Synthetixio#662)
1 parent c9a05a2 commit 4def75d

File tree

5 files changed

+26
-9
lines changed

5 files changed

+26
-9
lines changed

bin.js

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const {
66
getAST,
77
getSource,
88
getSuspensionReasons,
9+
getStakingRewards,
910
getSynths,
1011
getTarget,
1112
getUsers,
@@ -48,6 +49,14 @@ program
4849
console.log(networks);
4950
});
5051

52+
program
53+
.command('rewards')
54+
.description('Get staking rewards for an environment')
55+
.option('-n, --network <value>', 'The network to run off.', x => x.toLowerCase(), 'mainnet')
56+
.action(async ({ network }) => {
57+
console.log(JSON.stringify(getStakingRewards({ network }), null, 2));
58+
});
59+
5160
program
5261
.command('source')
5362
.description('Get source files for an environment')

publish/deployed/mainnet/rewards.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"rewardsToken": "0x330416C863f2acCE7aF9C9314B422d24c672534a"
2121
},
2222
{
23-
"name": "iETH",
23+
"name": "iETH3",
2424
"stakingToken": "ProxyiETH",
2525
"rewardsToken": "Synthetix"
2626
},

test/deployments/index.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,13 @@ describe('deployments', () => {
5858
target: stakingRewardsName,
5959
});
6060

61+
// these mappings are the getters for the legacy rewards contracts
6162
const methodMappings = {
62-
iETHRewards: {
63-
stakingTokenMethod: 'token',
64-
rewardsTokenMethod: 'snx',
65-
},
66-
Unipool: {
63+
StakingRewardssETHUniswapV1: {
6764
stakingTokenMethod: 'uni',
6865
rewardsTokenMethod: 'snx',
6966
},
70-
CurveRewards: {
67+
StakingRewardssUSDCurve: {
7168
stakingTokenMethod: 'uni',
7269
rewardsTokenMethod: 'snx',
7370
},
@@ -78,7 +75,10 @@ describe('deployments', () => {
7875

7976
// Legacy contracts have a different method name
8077
// to get staking tokens and rewards token
81-
if (stakingRewardsTarget.source !== 'StakingRewards') {
78+
if (
79+
!(stakingTokenMethod in stakingRewardsContract.methods) ||
80+
!(rewardsTokenMethod in stakingRewardsContract.methods)
81+
) {
8282
({ stakingTokenMethod, rewardsTokenMethod } = methodMappings[
8383
stakingRewardsTarget.source
8484
]);

test/etherscan/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ const program = new commander.Command();
88

99
program
1010
.option('-n, --network <value>', 'The network to run off.', x => x.toLowerCase(), 'mainnet')
11-
.action(async ({ network }) => {
11+
.option('-g, --grep <value>', 'Any grep string')
12+
.action(async ({ network, grep }) => {
1213
// setup the network as an env variable
1314
process.env.ETH_NETWORK = network;
1415

1516
const mocha = new Mocha({
1617
timeout: 10e3, // 10 secs
18+
grep,
1719
});
1820

1921
// Add each .js file to the mocha instance

test/etherscan/spec.js

+6
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ describe(`Etherscan on ${network}`, () => {
9898
const { encodeFunctionSignature, encodeEventSignature } = web3.eth.abi;
9999

100100
for (const { type, inputs, name, signature } of abi) {
101+
// when the ABI has no signature for an entry, skip it
102+
// this happens when the ABIs weren't generated in a build but
103+
// rather taken from Etherscan as was the case with early StakingRewards
104+
if (!signature) {
105+
continue;
106+
}
101107
if (type === 'function') {
102108
assert.strictEqual(
103109
encodeFunctionSignature({ name, inputs }),

0 commit comments

Comments
 (0)