Commit d0682fbb authored by George Hotz's avatar George Hotz

confirm the save worked

parent 5f9697f6
......@@ -18,6 +18,12 @@ contract MIPSMemory {
mapping(bytes32 => Preimage) public preimage;
function GetPreimage(bytes32 outhash, uint offset) public view returns (uint, uint32) {
uint64 data = preimage[outhash].data[offset];
require(data > 0, "offset not loaded");
return (preimage[outhash].length, uint32(data));
}
function AddPreimage(bytes calldata anything, uint offset) public {
require(offset & 3 == 0, "offset must be 32-bit aligned");
uint len = anything.length;
......
......@@ -40,12 +40,16 @@ describe("MIPSMemory contract", function () {
await mm.AddLargePreimageInit(4)
let dat = new TextEncoder("utf-8").encode("hello world")
let dathash = keccak256(dat)
const tst = await mm.AddLargePreimageFinal(dat)
expect(tst[0]).to.equal(keccak256(dat))
expect(tst[0]).to.equal(dathash)
expect(tst[1].toNumber()).to.equal(11)
expect(tst[2]).to.equal(0x6f20776f)
console.log(tst)
await mm.AddLargePreimageFinalSaved(dat)
let ret = await mm.GetPreimage(dathash, 4)
expect(ret[0].toNumber()).to.equal(11)
expect(ret[1]).to.equal(0x6f20776f)
})
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment