Skip to content

Commit

Permalink
Merge pull request #143 from Concordium/test-special-events
Browse files Browse the repository at this point in the history
TestSpecialEvents-PR1: Tested all BlockSpecialEvents
  • Loading branch information
rasmus-kirk committed Feb 23, 2023
2 parents ff648b4 + 33b0f9b commit 11d3872
Show file tree
Hide file tree
Showing 2 changed files with 230 additions and 0 deletions.
153 changes: 153 additions & 0 deletions packages/nodejs/test/resources/expectedJsons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,159 @@ export const delegationStakeDecreasedEvent = {
newStake: 10000000n,
};

export const mintSpecialEvent = {
tag: 'mint',
mintBakingReward: 12708081798618n,
mintFinalizationReward: 6354040899309n,
mintPlatformDevelopmentCharge: 2118013633103n,
foundationAccount: '3kBx2h5Y2veb4hZgAJWPrr8RyQESKm5TjzF3ti1QQ4VSYLwK1G',
};

export const paydayFoundationRewardSpecialEvent = {
tag: 'paydayFoundationReward',
foundationAccount: '3kBx2h5Y2veb4hZgAJWPrr8RyQESKm5TjzF3ti1QQ4VSYLwK1G',
developmentCharge: 103517862n,
};

export const paydayPoolRewardSpecialEvent = {
tag: 'paydayPoolReward',
transactionFees: 0n,
bakerReward: 0n,
finalizationReward: 0n,
};

export const paydayAccountRewardSpecialEvent = {
tag: 'paydayAccountReward',
account: '48XGRnvQoG92T1AwETvW5pnJ1aRSPMKsWtGdKhTqyiNZzMk3Qn',
transactionFees: 128913265n,
bakerReward: 1139222197711n,
finalizationReward: 577640081755n,
};

export const blockAccrueRewardSpecialEvent = {
tag: 'blockAccrueReward',
transactionFees: 0n,
oldGasAccount: 3n,
newGasAccount: 3n,
bakerReward: 0n,
passiveReward: 0n,
foundationCharge: 0n,
baker: 6n,
};

export const bakingRewardsSpecialEvent = {
tag: 'bakingRewards',
bakingRewards: [
{
account: '3QK1rxUXV7GRk4Ng7Bs7qnbkdjyBdjzCytpTrSQN7BaJkiEfgZ',
amount: 56740641000n,
},
{
account: '3U4sfVSqGG6XK8g6eho2qRYtnHc4MWJBG1dfxdtPGbfHwFxini',
amount: 32625868575n,
},
{
account: '3gGBYDSpx2zWL3YMcqD48U5jVXYG4pJBDZqeY5CbMMKpxVBbc3',
amount: 39718448700n,
},
{
account: '3ntvNGT6tDuLYiSb5gMJSQAZfLPUJnzoizcFiVRWqLoctuXxpK',
amount: 41136964725n,
},
{
account: '3y9DtDUL8xpf8i2yj9k44zMVkf4H1hkpBEQcXbJhrgcwYSGg41',
amount: 35462900625n,
},
{
account: '42tFTDWvTmBd7hEacohuCfGFa9TsBKhsmXKeViQ7q7NoY7UadV',
amount: 49648060875n,
},
{
account: '44Axe5eHnMkBinX7GKvUm5w6mX83JGdasijhvsMv5ZW2Wmgphg',
amount: 51066576900n,
},
{
account: '48XGRnvQoG92T1AwETvW5pnJ1aRSPMKsWtGdKhTqyiNZzMk3Qn',
amount: 35462900625n,
},
{
account: '4AnukgcopMC4crxfL1L9fUYw9MAkoo1yKLvH7eA1NAX7SxgyRY',
amount: 56740641000n,
},
{
account: '4BTFaHx8CioLi8Xe7YiimpAK1oQMkbx5Wj6B8N7d7NXgmLvEZs',
amount: 66670253175n,
},
{
account: '4EJJ1hVhbVZT2sR9xPzWUwFcJWK3fPX54z94zskTozFVk8Xd4L',
amount: 60996189075n,
},
],
remainder: 290n,
};

export const finalizationRewardsSpecialEvent = {
tag: 'finalizationRewards',
finalizationRewards: [
{
account: '3QK1rxUXV7GRk4Ng7Bs7qnbkdjyBdjzCytpTrSQN7BaJkiEfgZ',
amount: 359306692n,
},
{
account: '3U4sfVSqGG6XK8g6eho2qRYtnHc4MWJBG1dfxdtPGbfHwFxini',
amount: 359306692n,
},
{
account: '3gGBYDSpx2zWL3YMcqD48U5jVXYG4pJBDZqeY5CbMMKpxVBbc3',
amount: 359306692n,
},
{
account: '3ntvNGT6tDuLYiSb5gMJSQAZfLPUJnzoizcFiVRWqLoctuXxpK',
amount: 359306692n,
},
{
account: '3y9DtDUL8xpf8i2yj9k44zMVkf4H1hkpBEQcXbJhrgcwYSGg41',
amount: 359306692n,
},
{
account: '42tFTDWvTmBd7hEacohuCfGFa9TsBKhsmXKeViQ7q7NoY7UadV',
amount: 359306692n,
},
{
account: '44Axe5eHnMkBinX7GKvUm5w6mX83JGdasijhvsMv5ZW2Wmgphg',
amount: 359306692n,
},
{
account: '48XGRnvQoG92T1AwETvW5pnJ1aRSPMKsWtGdKhTqyiNZzMk3Qn',
amount: 359306692n,
},
{
account: '4AnukgcopMC4crxfL1L9fUYw9MAkoo1yKLvH7eA1NAX7SxgyRY',
amount: 359306692n,
},
{
account: '4BTFaHx8CioLi8Xe7YiimpAK1oQMkbx5Wj6B8N7d7NXgmLvEZs',
amount: 359306692n,
},
{
account: '4EJJ1hVhbVZT2sR9xPzWUwFcJWK3fPX54z94zskTozFVk8Xd4L',
amount: 359306692n,
},
],
remainder: 4n,
};

export const blockRewardSpecialEvent = {
tag: 'blockReward',
transactionFees: 0n,
oldGasAccount: 0n,
newGasAccount: 0n,
bakerReward: 0n,
foundationCharge: 0n,
baker: '44Axe5eHnMkBinX7GKvUm5w6mX83JGdasijhvsMv5ZW2Wmgphg',
foundationAccount: '44Axe5eHnMkBinX7GKvUm5w6mX83JGdasijhvsMv5ZW2Wmgphg',
};

export const insufficientBalanceForDelegationStakeRejectReason = {
tag: 'InsufficientBalanceForDelegationStake',
};
Expand Down
77 changes: 77 additions & 0 deletions packages/nodejs/test/specialEvents.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import * as expected from './resources/expectedJsons';
import { asyncIterableToList } from '@concordium/common-sdk/src/util';
import { getNodeClientV2 } from './testHelpers';

const client = getNodeClientV2();

test('mint', async () => {
const blockHash =
'4031d210b35a3fb9f13d1ce6e5c621abd9a26a2de54b71fc19bfb55fe17cce6a';
const eventStream = client.getBlockSpecialEvents(blockHash);
const events = await asyncIterableToList(eventStream);

expect(events[0]).toEqual(expected.mintSpecialEvent);
});

test('paydayFoundationReward', async () => {
const blockHash =
'4031d210b35a3fb9f13d1ce6e5c621abd9a26a2de54b71fc19bfb55fe17cce6a';
const eventStream = client.getBlockSpecialEvents(blockHash);
const events = await asyncIterableToList(eventStream);

expect(events[1]).toEqual(expected.paydayFoundationRewardSpecialEvent);
});

test('paydayPoolReward', async () => {
const blockHash =
'4031d210b35a3fb9f13d1ce6e5c621abd9a26a2de54b71fc19bfb55fe17cce6a';
const eventStream = client.getBlockSpecialEvents(blockHash);
const events = await asyncIterableToList(eventStream);

expect(events[2]).toEqual(expected.paydayPoolRewardSpecialEvent);
});

test('paydayAccountReward', async () => {
const blockHash =
'4031d210b35a3fb9f13d1ce6e5c621abd9a26a2de54b71fc19bfb55fe17cce6a';
const eventStream = client.getBlockSpecialEvents(blockHash);
const events = await asyncIterableToList(eventStream);

expect(events[4]).toEqual(expected.paydayAccountRewardSpecialEvent);
});

test('blockAccrueReward', async () => {
const blockHash =
'4031d210b35a3fb9f13d1ce6e5c621abd9a26a2de54b71fc19bfb55fe17cce6a';
const eventStream = client.getBlockSpecialEvents(blockHash);
const events = await asyncIterableToList(eventStream);

expect(events[25]).toEqual(expected.blockAccrueRewardSpecialEvent);
});

test('bakingRewards', async () => {
const blockHash =
'da7a5401049c8ee0de0b6c66ab4f6167ef770b332df9dd9979ec2c553d1a18dd';
const eventStream = client.getBlockSpecialEvents(blockHash);
const events = await asyncIterableToList(eventStream);

expect(events[0]).toEqual(expected.bakingRewardsSpecialEvent);
});

test('finalizationRewards', async () => {
const blockHash =
'da7a5401049c8ee0de0b6c66ab4f6167ef770b332df9dd9979ec2c553d1a18dd';
const eventStream = client.getBlockSpecialEvents(blockHash);
const events = await asyncIterableToList(eventStream);

expect(events[2]).toEqual(expected.finalizationRewardsSpecialEvent);
});

test('blockReward', async () => {
const blockHash =
'da7a5401049c8ee0de0b6c66ab4f6167ef770b332df9dd9979ec2c553d1a18dd';
const eventStream = client.getBlockSpecialEvents(blockHash);
const events = await asyncIterableToList(eventStream);

expect(events[3]).toEqual(expected.blockRewardSpecialEvent);
});

0 comments on commit 11d3872

Please sign in to comment.