bond to override lock limit

This commit is contained in:
hueso
2024-03-03 21:58:41 -03:00
parent c25fa24b2f
commit 9b6617a702
7 changed files with 91 additions and 9 deletions

View File

@@ -622,6 +622,7 @@ describe("P2PIX", () => {
price,
[],
[],
false,
);
const fail2 = p2pix.lock(
zero,
@@ -629,6 +630,7 @@ describe("P2PIX", () => {
price,
[],
[],
false,
);
await expect(fail).to.be.revertedWithCustomError(
@@ -658,6 +660,7 @@ describe("P2PIX", () => {
price.mul(ethers.BigNumber.from(2)),
[],
[],
false,
);
await expect(fail).to.be.revertedWithCustomError(
@@ -683,6 +686,7 @@ describe("P2PIX", () => {
ethers.BigNumber.from(1000),
[ethers.utils.keccak256(ethers.utils.toUtf8Bytes("wrong"))],
[],
false,
);
await expect(fail).to.be.revertedWithCustomError(
@@ -710,6 +714,7 @@ describe("P2PIX", () => {
price.mul(2),
[],
[],
false,
);
await expect(fail).to.be.revertedWithCustomError(
@@ -717,6 +722,42 @@ describe("P2PIX", () => {
P2PixErrors.AmountNotAllowed,
);
});
it("should override spend limit if buyer pays the bond", async () => {
await erc20.approve(
p2pix.address,
price.mul(3),
);
await p2pix.deposit(
"1",
merkleRoot,
erc20.address,
price.mul(3),
true,
);
await erc20
.transfer(
acc02.address,
price,
);
await erc20
.connect(acc02)
.approve(
p2pix.address,
price.mul(30000),
);
const bond = p2pix
.connect(acc02)
.lock(
owner.address,
erc20.address,
price.mul(2),
[],
[],
true,
);
await expect(bond).to.be.ok;
});
it("should create a lock, update storage and emit events via the allowlist path", async () => {
const target = "333";
await erc20.approve(p2pix.address, price);
@@ -735,6 +776,7 @@ describe("P2PIX", () => {
price,
proof,
[],
false,
);
const storage: Lock = await p2pix.callStatic.mapLocks(
1,
@@ -779,6 +821,7 @@ describe("P2PIX", () => {
price,
[],
[],
false,
);
const storage: Lock = await p2pix.callStatic.mapLocks(
1,
@@ -840,6 +883,7 @@ describe("P2PIX", () => {
price,
[],
[],
false,
);
await p2pix
.connect(acc01)
@@ -856,6 +900,7 @@ describe("P2PIX", () => {
price.add(ethers.constants.One),
[],
[],
false,
);
const storage: Lock = await p2pix.callStatic.mapLocks(
2,
@@ -906,6 +951,7 @@ describe("P2PIX", () => {
newPrice,
proof,
[],
false,
);
const storage1: Lock = await p2pix.callStatic.mapLocks(
1,
@@ -922,6 +968,7 @@ describe("P2PIX", () => {
ethers.BigNumber.from(100),
[],
[],
false,
);
const storage2: Lock = await p2pix.callStatic.mapLocks(
2,
@@ -938,6 +985,7 @@ describe("P2PIX", () => {
ethers.BigNumber.from(100),
[],
[],
false,
);
const storage3: Lock = await p2pix.callStatic.mapLocks(
3,
@@ -1214,6 +1262,7 @@ describe("P2PIX", () => {
ethers.BigNumber.from(100),
[],
[],
false,
);
const lockID = ethers.constants.One;
await mine(13);
@@ -1255,6 +1304,7 @@ describe("P2PIX", () => {
ethers.BigNumber.from(100),
[],
[],
false,
);
const lockID = ethers.constants.One;
await p2pix.release(
@@ -1299,6 +1349,7 @@ describe("P2PIX", () => {
ethers.BigNumber.from(100),
[],
[],
false,
);
await p2pix
@@ -1316,6 +1367,7 @@ describe("P2PIX", () => {
ethers.BigNumber.from(100),
[],
[],
false,
);
const fail = p2pix
.connect(acc01)
@@ -1357,6 +1409,7 @@ describe("P2PIX", () => {
ethers.BigNumber.from(100),
[],
[],
false,
);
const fail = p2pix
.connect(acc01)
@@ -1413,6 +1466,7 @@ describe("P2PIX", () => {
ethers.BigNumber.from(100),
[],
[],
false,
);
const acc01Key = await p2pix.callStatic._castAddrToKey(
acc01.address,
@@ -1577,6 +1631,7 @@ describe("P2PIX", () => {
ethers.BigNumber.from(100),
[],
[],
false,
);
await p2pix
.connect(acc03)
@@ -1586,6 +1641,7 @@ describe("P2PIX", () => {
ethers.BigNumber.from(50),
[],
[],
false,
);
await p2pix
.connect(acc03)
@@ -1595,6 +1651,7 @@ describe("P2PIX", () => {
ethers.BigNumber.from(25),
[],
[],
false,
);
const lockStatus1 =
@@ -1764,6 +1821,7 @@ describe("P2PIX", () => {
ethers.constants.One,
[],
[],
false,
);
const lockID = ethers.constants.One;
const fail = p2pix.unlockExpired([lockID]);
@@ -1802,6 +1860,7 @@ describe("P2PIX", () => {
ethers.constants.One,
[],
[],
false,
);
const lockID = ethers.constants.One;
// await mine(10);
@@ -1835,6 +1894,7 @@ describe("P2PIX", () => {
ethers.constants.One,
[],
[],
false,
);
const lockID = ethers.constants.One;
await mine(11);
@@ -1898,6 +1958,7 @@ describe("P2PIX", () => {
price,
proof,
[],
false,
);
// as return values of non view functions can't be accessed
// outside the evm, we fetch the lockID from the emitted event.
@@ -1937,6 +1998,7 @@ describe("P2PIX", () => {
ethers.BigNumber.from(100),
[],
[lockID],
false
);
const remaining = await p2pix.callStatic.getBalance(
owner.address,
@@ -1970,6 +2032,7 @@ describe("P2PIX", () => {
price,
proof,
[],
false,
);
const lockID = ethers.constants.One;
// mine blocks to expire lock