From 42ccd1bd3213f2b00dbf3f6e8fb169729226cd94 Mon Sep 17 00:00:00 2001 From: Manuel Polzhofer Date: Fri, 4 Oct 2019 07:33:45 +0200 Subject: [PATCH] added version to tinlake (#71) --- src/reception.sol | 8 +++++++- src/test/reception.t.sol | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/reception.sol b/src/reception.sol index f55d5076..2246b8a3 100644 --- a/src/reception.sol +++ b/src/reception.sol @@ -45,11 +45,12 @@ contract Reception is TitleOwned { modifier auth { require(wards[msg.sender] == 1); _; } // --- Data --- - DeskLike desk; ShelfLike shelf; PileLike pile; + bytes32 public version; + constructor (address desk_, address title_, address shelf_, address pile_) TitleOwned(title_) public { wards[msg.sender] = 1; desk = DeskLike(desk_); @@ -57,6 +58,11 @@ contract Reception is TitleOwned { pile = PileLike(pile_); } + function file(bytes32 what, bytes32 data) public auth { + if (what == "version") version = data; + else revert(); + } + // --- Reception --- function borrow(uint loan, address deposit) public owner(loan) { shelf.deposit(loan, msg.sender); diff --git a/src/test/reception.t.sol b/src/test/reception.t.sol index ca2c0feb..63653d96 100644 --- a/src/test/reception.t.sol +++ b/src/test/reception.t.sol @@ -123,6 +123,18 @@ contract ReceptionTest is DSTest { repay(loan, principal); } + function testFileVersion() public { + bytes32 version = keccak256("1"); + reception.file("version",version); + assertEq(version, reception.version()); + } + + function testFailFileVersion() public { + bytes32 version = keccak256("1"); + reception.file("wrong",version); + assertEq(version, reception.version()); + } + function testClose() public { uint loan = 1; uint principal = 500;