Commit 2ef57c8c authored by George Hotz's avatar George Hotz

test is wrong

parent a5e93d4e
...@@ -35,8 +35,15 @@ contract MIPSMemory { ...@@ -35,8 +35,15 @@ contract MIPSMemory {
largePreimage[msg.sender] = c.A; largePreimage[msg.sender] = c.A;
} }
function AddLargePreimageFinal(uint64[17] calldata data) public { function AddLargePreimageFinal() public view returns (bytes32) {
Lib_Keccak256.CTX memory c;
c.A = largePreimage[msg.sender];
// TODO: do this properly and save the hash // TODO: do this properly and save the hash
// when this is updated, it won't be "view"
return bytes32((uint256(c.A[0]) << 192) |
(uint256(c.A[1]) << 128) |
(uint256(c.A[2]) << 64) |
c.A[3]);
} }
function AddMerkleState(bytes32 stateHash, uint32 addr, uint32 value, string calldata proof) public { function AddMerkleState(bytes32 stateHash, uint32 addr, uint32 value, string calldata proof) public {
......
const { keccak256 } = require("@ethersproject/keccak256");
const { expect } = require("chai"); const { expect } = require("chai");
describe("MIPSMemory contract", function () { describe("MIPSMemory contract", function () {
...@@ -11,11 +12,15 @@ describe("MIPSMemory contract", function () { ...@@ -11,11 +12,15 @@ describe("MIPSMemory contract", function () {
await mm.AddLargePreimageInit(); await mm.AddLargePreimageInit();
console.log("preimage initted"); console.log("preimage initted");
var a = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; const a = ["0x0100000000000000",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x80];
await mm.AddLargePreimageUpdate(a); await mm.AddLargePreimageUpdate(a);
console.log("preimage updated"); console.log("preimage updated");
var tst = await mm.largePreimage(owner.address, 0); /*var tst1 = await mm.largePreimage(owner.address, 0);
console.log(tst); console.log(tst);*/
const hash = await mm.AddLargePreimageFinal();
console.log("comp hash is", hash);
console.log("real hash is", keccak256(new Uint8Array(0)));
}); });
}); });
\ 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