Skip to content

Commit

Permalink
feat: added test for repay with max input (-1)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaquinBattilana committed Sep 15, 2023
1 parent 529ca8b commit 8d191bf
Showing 1 changed file with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,22 @@ describe('PoolBundle', () => {
);
});

it('generates repay tx data with generateTxData with variable debt and max input', () => {
const result = instance.repayTxBuilder.generateTxData({
user: USER,
reserve: TOKEN,
amount: '-1',
interestRateMode: InterestRate.Variable,
onBehalfOf: USER,
});

expect(result.to).toEqual(POOL);
expect(result.from).toEqual(USER);
expect(result.data).toEqual(
'0x573ade810000000000000000000000000000000000000000000000000000000000000004ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003',
);
});

it('generates repay tx data with generateTxData with stable debt', () => {
const result = instance.repayTxBuilder.generateTxData({
user: USER,
Expand Down Expand Up @@ -685,6 +701,24 @@ describe('PoolBundle', () => {
);
});

it('generates signed tx with generateSignedTxData with variable debt and max input', () => {
const result = instance.repayTxBuilder.generateSignedTxData({
user: USER,
reserve: TOKEN,
amount: '-1',
onBehalfOf: USER,
interestRateMode: InterestRate.Variable,
signature:
'0x532f8df4e2502bd869fb35e9301156f9b307380afdcc25cfbc87b2e939f16f7e47c326dc26eb918d327358797ee67ad7415d871ef7eaf0d4f6352d3ad021fbb41c',
deadline: '10000',
});
expect(result.to).toEqual(POOL);
expect(result.from).toEqual(USER);
expect(result.data).toEqual(
'0xee3e210b0000000000000000000000000000000000000000000000000000000000000004ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000002710000000000000000000000000000000000000000000000000000000000000001c532f8df4e2502bd869fb35e9301156f9b307380afdcc25cfbc87b2e939f16f7e47c326dc26eb918d327358797ee67ad7415d871ef7eaf0d4f6352d3ad021fbb4',
);
});

it('generates signed tx with generateSignedTxData with stable debt', () => {
const result = instance.repayTxBuilder.generateSignedTxData({
user: USER,
Expand Down Expand Up @@ -732,6 +766,21 @@ describe('PoolBundle', () => {
);
});

it('generates repayWithAToken tx data with generateTxData with variable rate and max input', () => {
const result = instance.repayWithATokensTxBuilder.generateTxData({
user: USER,
reserve: TOKEN,
amount: '-1',
rateMode: InterestRate.Variable,
});

expect(result.to).toEqual(POOL);
expect(result.from).toEqual(USER);
expect(result.data).toEqual(
'0x2dad97d40000000000000000000000000000000000000000000000000000000000000004ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000002',
);
});

it('generates repayWithAToken tx data with generateTxData with stable debt', () => {
const result = instance.repayWithATokensTxBuilder.generateTxData({
user: USER,
Expand Down

0 comments on commit 8d191bf

Please sign in to comment.