Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HananINouman committed Sep 9, 2024
1 parent ad86567 commit 4ba796b
Showing 1 changed file with 81 additions and 2 deletions.
83 changes: 81 additions & 2 deletions test/sdk-package-test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,56 @@ describe('Cluster Definition', () => {
});

expect(withdrawalAddress.length).toEqual(42);

expect(feeRecipientAddress.length).toEqual(42);

expect(contractsWithSameFeeRecipientAddress.withdrawalAddress.length).toEqual(42);
expect(feeRecipientAddress.toLowerCase()).toEqual(
contractsWithSameFeeRecipientAddress.feeRecipientAddress.toLowerCase(),
);
});

it('should deploy OWR and Splitter with a controller address and a distributorFee', async () => {
const signerAddress = await randomSigner.getAddress();
// new splitter
const { withdrawalAddress, feeRecipientAddress } =
await client.createObolRewardSplit({
splitRecipients: [
{ account: signerAddress, percentAllocation: 39 },
{
account: '0xf6fF1a7A14D01e86a175bA958d3B6C75f2213966',
percentAllocation: 60,
},
],
principalRecipient: '0xf6fF1a7A14D01e86a175bA958d3B6C75f2213966',
validatorsSize: 2,
distributorFee: 2,
controllerAddress: '0xf6fF1a7A14D01e86a175bA958d3B6C75f2213966'
});

// same splitter
const contractsWithDifferentFeeRecipient =
await client.createObolRewardSplit({
splitRecipients: [
{ account: signerAddress, percentAllocation: 39 },
{
account: '0xf6fF1a7A14D01e86a175bA958d3B6C75f2213966',
percentAllocation: 60,
},
],
principalRecipient: '0xf6fF1a7A14D01e86a175bA958d3B6C75f2213966',
validatorsSize: 2,
distributorFee: 2,
controllerAddress: '0xf6fF1a7A14D01e86a175bA958d3B6C75f2213966'
});

expect(withdrawalAddress.length).toEqual(42);
expect(feeRecipientAddress.length).toEqual(42);
expect(contractsWithDifferentFeeRecipient.withdrawalAddress.length).toEqual(42);
expect(contractsWithDifferentFeeRecipient.feeRecipientAddress.length).toEqual(42);
expect(feeRecipientAddress.toLowerCase()).not.toEqual(
contractsWithDifferentFeeRecipient.feeRecipientAddress.toLowerCase(),
);
});

it('should deploy Splitter', async () => {
const secondRandomSignerAddress = await secondRandomSigner.getAddress();
// new splitter
Expand Down Expand Up @@ -206,6 +248,43 @@ describe('Cluster Definition', () => {
);
});

it('should deploy Splitter with distributorFee and controller address', async () => {
const secondRandomSignerAddress = await secondRandomSigner.getAddress();
// new splitter
const { withdrawalAddress, feeRecipientAddress } =
await client.createObolTotalSplit({
splitRecipients: [
{ account: secondRandomSignerAddress, percentAllocation: 39.9 },
{
account: '0xf6fF1a7A14D01e86a175bA958d3B6C75f2213966',
percentAllocation: 60,
},
],
distributorFee: 2,
controllerAddress: '0xf6fF1a7A14D01e86a175bA958d3B6C75f2213966',
});

// same splitter
const contractsWithDifferentFeeRecipient =
await client.createObolTotalSplit({
splitRecipients: [
{ account: secondRandomSignerAddress, percentAllocation: 39.9 },
{
account: '0xf6fF1a7A14D01e86a175bA958d3B6C75f2213966',
percentAllocation: 60,
},
],
});

expect(withdrawalAddress.length).toEqual(42);
expect(feeRecipientAddress.toLowerCase()).toEqual(withdrawalAddress.toLowerCase());
expect(contractsWithDifferentFeeRecipient.withdrawalAddress.length).toEqual(42);
expect(contractsWithDifferentFeeRecipient.feeRecipientAddress.toLowerCase()).toEqual(contractsWithDifferentFeeRecipient.withdrawalAddress.toLowerCase());
expect(feeRecipientAddress.toLowerCase()).not.toEqual(
contractsWithDifferentFeeRecipient.feeRecipientAddress.toLowerCase(),
);
});

afterAll(async () => {
await request(app)
.delete(`/v1/definition/${configHash}`)
Expand Down

0 comments on commit 4ba796b

Please sign in to comment.