|
|
@ -11,25 +11,22 @@ describe("Git3 Test", function () {
|
|
|
|
const git3 = await Git3.deploy();
|
|
|
|
const git3 = await Git3.deploy();
|
|
|
|
await git3.deployed();
|
|
|
|
await git3.deployed();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let singer;
|
|
|
|
|
|
|
|
[singer] = await ethers.getSigners();
|
|
|
|
|
|
|
|
console.log("singer", singer.address);
|
|
|
|
|
|
|
|
|
|
|
|
await git3.upload("0x616263", "0x112233");
|
|
|
|
await git3.upload("0x616263", "0x112233");
|
|
|
|
expect(await git3.download("0x616263")).to.eql(["0x112233", true]);
|
|
|
|
expect(await git3.download("0x616263")).to.eql(["0x112233", true]);
|
|
|
|
|
|
|
|
|
|
|
|
let data = Array.from({ length: 40 }, () =>
|
|
|
|
let data = Array.from({ length: 40 }, () => Math.floor(Math.random() * 256));
|
|
|
|
Math.floor(Math.random() * 256)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await git3.upload("0x616263", data);
|
|
|
|
await git3.upload("0x616263", data);
|
|
|
|
expect(await git3.download("0x616263")).to.eql([
|
|
|
|
expect(await git3.download("0x616263")).to.eql([ethers.utils.hexlify(data), true]);
|
|
|
|
ethers.utils.hexlify(data),
|
|
|
|
|
|
|
|
true,
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(await git3.size("0x616263")).to.eql([ToBig(40), ToBig(1)]);
|
|
|
|
expect(await git3.size("0x616263")).to.eql([ToBig(40), ToBig(1)]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await git3.remove("0x616263");
|
|
|
|
await git3.remove("0x616263");
|
|
|
|
expect(await git3.size("0x616263")).to.eql([ToBig(0), ToBig(0)]);
|
|
|
|
expect(await git3.size("0x616263")).to.eql([ToBig(0), ToBig(0)]);
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("upload/download/remove chunks", async function () {
|
|
|
|
it("upload/download/remove chunks", async function () {
|
|
|
@ -39,30 +36,17 @@ describe("Git3 Test", function () {
|
|
|
|
|
|
|
|
|
|
|
|
expect(await git3.countChunks("0x616263")).to.eql(ToBig(0));
|
|
|
|
expect(await git3.countChunks("0x616263")).to.eql(ToBig(0));
|
|
|
|
|
|
|
|
|
|
|
|
let data0 = Array.from({ length: 10 }, () =>
|
|
|
|
let data0 = Array.from({ length: 10 }, () => Math.floor(Math.random() * 256));
|
|
|
|
Math.floor(Math.random() * 256)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
await git3.uploadChunk("0x616263", 0, data0);
|
|
|
|
await git3.uploadChunk("0x616263", 0, data0);
|
|
|
|
expect(await git3.download("0x616263")).to.eql([
|
|
|
|
expect(await git3.download("0x616263")).to.eql([ethers.utils.hexlify(data0), true]);
|
|
|
|
ethers.utils.hexlify(data0),
|
|
|
|
|
|
|
|
true,
|
|
|
|
let data1 = Array.from({ length: 20 }, () => Math.floor(Math.random() * 256));
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let data1 = Array.from({ length: 20 }, () =>
|
|
|
|
|
|
|
|
Math.floor(Math.random() * 256)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
await git3.uploadChunk("0x616263", 1, data1);
|
|
|
|
await git3.uploadChunk("0x616263", 1, data1);
|
|
|
|
expect(await git3.download("0x616263")).to.eql([
|
|
|
|
expect(await git3.download("0x616263")).to.eql([ethers.utils.hexlify(data0.concat(data1)), true]);
|
|
|
|
ethers.utils.hexlify(data0.concat(data1)),
|
|
|
|
|
|
|
|
true,
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await git3.remove("0x616263"); // should succeed
|
|
|
|
await git3.remove("0x616263"); // should succeed
|
|
|
|
expect(await git3.size("0x616263")).to.eql([ToBig(0), ToBig(0)]);
|
|
|
|
expect(await git3.size("0x616263")).to.eql([ToBig(0), ToBig(0)]);
|
|
|
|
expect(await git3.download("0x616263")).to.eql([
|
|
|
|
expect(await git3.download("0x616263")).to.eql(["0x", false]);
|
|
|
|
"0x",
|
|
|
|
|
|
|
|
false,
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
expect(await git3.countChunks("0x616263")).to.eql(ToBig(0));
|
|
|
|
expect(await git3.countChunks("0x616263")).to.eql(ToBig(0));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -83,7 +67,6 @@ describe("Git3 Test", function () {
|
|
|
|
let data2 = "0xcccccccccccccccccccccccccccccccccccccccc";
|
|
|
|
let data2 = "0xcccccccccccccccccccccccccccccccccccccccc";
|
|
|
|
await git3.setRef(key2, data2);
|
|
|
|
await git3.setRef(key2, data2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let refs = await git3.listRefs();
|
|
|
|
let refs = await git3.listRefs();
|
|
|
|
expect(refs[0]).to.eql([data0, key0]);
|
|
|
|
expect(refs[0]).to.eql([data0, key0]);
|
|
|
|
expect(refs[1]).to.eql([data1, key1]);
|
|
|
|
expect(refs[1]).to.eql([data1, key1]);
|
|
|
@ -107,7 +90,5 @@ describe("Git3 Test", function () {
|
|
|
|
await git3.setRef(key2, data3);
|
|
|
|
await git3.setRef(key2, data3);
|
|
|
|
refs = await git3.listRefs();
|
|
|
|
refs = await git3.listRefs();
|
|
|
|
expect(refs[0]).to.eql([data3, key2]);
|
|
|
|
expect(refs[0]).to.eql([data3, key2]);
|
|
|
|
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|