Skip to content

Commit d6b4afd

Browse files
committed
fix : fixes and changes for review
1 parent 86dc0ee commit d6b4afd

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

tests/unit/TestGhoBase.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ contract TestGhoBase is Test, Constants, Events {
725725
(v, r, s) = vm.sign(ownerPk, outerHash);
726726
}
727727

728-
function _getBuyTypedDataHash(
728+
function _getBuyAssetTypedDataHash(
729729
EIP712Types.BuyAssetWithSig memory params
730730
) internal view returns (bytes32) {
731731
return
@@ -738,7 +738,7 @@ contract TestGhoBase is Test, Constants, Events {
738738
);
739739
}
740740

741-
function _getSellTypedDataHash(
741+
function _getSellAssetTypedDataHash(
742742
EIP712Types.SellAssetWithSig memory params
743743
) internal view returns (bytes32) {
744744
return

tests/unit/TestGsm.t.sol

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.0;
33

4-
import {EIP712Types} from '../helpers/EIP712Types.sol';
5-
64
import './TestGhoBase.t.sol';
75

86
contract TestGsm is TestGhoBase {
@@ -93,6 +91,13 @@ contract TestGsm is TestGhoBase {
9391
gsm.initialize(address(this), TREASURY, DEFAULT_GSM_USDX_EXPOSURE, address(GHO_RESERVE));
9492
}
9593

94+
function testTypehash() public {
95+
bytes32 buyTypeHash = vm.eip712HashType('BuyAssetWithSig');
96+
bytes32 sellTypeHash = vm.eip712HashType('SellAssetWithSig');
97+
assertEq(buyTypeHash, GHO_GSM.BUY_ASSET_WITH_SIG_TYPEHASH(), 'Unexpected buy asset typed data hash');
98+
assertEq(sellTypeHash, GHO_GSM.SELL_ASSET_WITH_SIG_TYPEHASH(), 'Unexpected sell asset typed data hash');
99+
}
100+
96101
function testSellAssetZeroFee() public {
97102
vm.expectEmit(true, true, false, true, address(GHO_GSM));
98103
emit FeeStrategyUpdated(address(GHO_GSM_FIXED_FEE_STRATEGY), address(0));
@@ -183,7 +188,7 @@ contract TestGsm is TestGhoBase {
183188

184189
assertEq(GHO_GSM.nonces(gsmSignerAddr), 0, 'Unexpected before gsmSignerAddr nonce');
185190

186-
bytes32 digest = _getSellTypedDataHash(
191+
bytes32 digest = _getSellAssetTypedDataHash(
187192
EIP712Types.SellAssetWithSig({
188193
originator: gsmSignerAddr,
189194
maxAmount: DEFAULT_GSM_USDX_AMOUNT,
@@ -236,7 +241,7 @@ contract TestGsm is TestGhoBase {
236241

237242
assertEq(GHO_GSM.nonces(gsmSignerAddr), 0, 'Unexpected before gsmSignerAddr nonce');
238243

239-
bytes32 digest = _getSellTypedDataHash(
244+
bytes32 digest = _getSellAssetTypedDataHash(
240245
EIP712Types.SellAssetWithSig({
241246
originator: gsmSignerAddr,
242247
maxAmount: DEFAULT_GSM_USDX_AMOUNT,
@@ -278,7 +283,7 @@ contract TestGsm is TestGhoBase {
278283
function testRevertSellAssetWithSigExpiredSignature() public {
279284
uint256 deadline = block.timestamp - 1;
280285

281-
bytes32 digest = _getSellTypedDataHash(
286+
bytes32 digest = _getSellAssetTypedDataHash(
282287
EIP712Types.SellAssetWithSig({
283288
originator: gsmSignerAddr,
284289
maxAmount: DEFAULT_GSM_USDX_AMOUNT,
@@ -307,7 +312,7 @@ contract TestGsm is TestGhoBase {
307312
function testRevertSellAssetWithSigInvalidSignature() public {
308313
uint256 deadline = block.timestamp + 1 hours;
309314

310-
bytes32 digest = _getSellTypedDataHash(
315+
bytes32 digest = _getSellAssetTypedDataHash(
311316
EIP712Types.SellAssetWithSig({
312317
originator: gsmSignerAddr,
313318
maxAmount: DEFAULT_GSM_USDX_AMOUNT,
@@ -584,7 +589,7 @@ contract TestGsm is TestGhoBase {
584589

585590
assertEq(GHO_GSM.nonces(gsmSignerAddr), 0, 'Unexpected before gsmSignerAddr nonce');
586591

587-
bytes32 digest = _getBuyTypedDataHash(
592+
bytes32 digest = _getBuyAssetTypedDataHash(
588593
EIP712Types.BuyAssetWithSig({
589594
originator: gsmSignerAddr,
590595
minAmount: DEFAULT_GSM_USDX_AMOUNT,
@@ -652,7 +657,7 @@ contract TestGsm is TestGhoBase {
652657

653658
assertEq(GHO_GSM.nonces(gsmSignerAddr), 0, 'Unexpected before gsmSignerAddr nonce');
654659

655-
bytes32 digest = _getBuyTypedDataHash(
660+
bytes32 digest = _getBuyAssetTypedDataHash(
656661
EIP712Types.BuyAssetWithSig({
657662
originator: gsmSignerAddr,
658663
minAmount: DEFAULT_GSM_USDX_AMOUNT,
@@ -745,7 +750,7 @@ contract TestGsm is TestGhoBase {
745750
function testRevertBuyAssetWithSigExpiredSignature() public {
746751
uint256 deadline = block.timestamp - 1;
747752

748-
bytes32 digest = _getBuyTypedDataHash(
753+
bytes32 digest = _getBuyAssetTypedDataHash(
749754
EIP712Types.BuyAssetWithSig({
750755
originator: gsmSignerAddr,
751756
minAmount: DEFAULT_GSM_USDX_AMOUNT,
@@ -773,7 +778,7 @@ contract TestGsm is TestGhoBase {
773778
function testRevertBuyAssetWithSigInvalidSignature() public {
774779
uint256 deadline = block.timestamp + 1 hours;
775780

776-
bytes32 digest = _getBuyTypedDataHash(
781+
bytes32 digest = _getBuyAssetTypedDataHash(
777782
EIP712Types.BuyAssetWithSig({
778783
originator: gsmSignerAddr,
779784
minAmount: DEFAULT_GSM_USDX_AMOUNT,

0 commit comments

Comments
 (0)