Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/concrete/AlwaysAuthorize.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: LicenseRef-DCL-1.0
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity =0.8.25;

import {IAuthorizeV1} from "src/concrete/vault/OffchainAssetReceiptVault.sol";
import {IERC165} from "@openzeppelin-contracts-5.6.1/utils/introspection/IERC165.sol";

contract AlwaysAuthorize is IAuthorizeV1, IERC165 {
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) external pure override returns (bool) {
return interfaceId == type(IAuthorizeV1).interfaceId || interfaceId == type(IERC165).interfaceId;
}

/// @inheritdoc IAuthorizeV1
function authorize(address, bytes32, bytes memory) external pure override {}
}
72 changes: 72 additions & 0 deletions test/concrete/MutableMetadataReceipt.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// SPDX-License-Identifier: LicenseRef-DCL-1.0
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity =0.8.25;

import {ERC20PriceOracleReceipt} from "src/concrete/receipt/ERC20PriceOracleReceipt.sol";

/// This contract is used to test the metadata of the `Receipt` contract.
/// As all the overridden functions are internal, we need to create a new
/// contract that inherits from `Receipt` and exposes these functions; we can't
/// just mock `Receipt`.
contract MutableMetadataReceipt is ERC20PriceOracleReceipt {
string internal sVaultShareSymbol;
string internal sVaultAssetSymbol;
//forge-lint: disable-next-line(mixed-case-variable)
string internal sReceiptSVGURI;
string internal sReferenceAssetSymbol;
//forge-lint: disable-next-line(mixed-case-variable)
string internal sRedeemURL;
string internal sBrandName;

function setVaultShareSymbol(string memory vaultShareSymbol) external {
sVaultShareSymbol = vaultShareSymbol;
}

function setVaultAssetSymbol(string memory vaultAssetSymbol) external {
sVaultAssetSymbol = vaultAssetSymbol;
}

//forge-lint: disable-next-line(mixed-case-function,mixed-case-variable)
function setReceiptSVGURI(string memory receiptSVGURI) external {
sReceiptSVGURI = receiptSVGURI;
}

function setReferenceAssetSymbol(string memory referenceAssetSymbol) external {
sReferenceAssetSymbol = referenceAssetSymbol;
}

//forge-lint: disable-next-line(mixed-case-function,mixed-case-variable)
function setRedeemURL(string memory redeemURL) external {
sRedeemURL = redeemURL;
}

function setBrandName(string memory brandName) external {
sBrandName = brandName;
}

function _vaultShareSymbol() internal view override returns (string memory) {
return sVaultShareSymbol;
}

function _vaultAssetSymbol() internal view override returns (string memory) {
return sVaultAssetSymbol;
}

//forge-lint: disable-next-line(mixed-case-function)
function _receiptSVGURI() internal view override returns (string memory) {
return sReceiptSVGURI;
}

function _referenceAssetSymbol() internal view override returns (string memory) {
return sReferenceAssetSymbol;
}

//forge-lint: disable-next-line(mixed-case-function)
function _redeemURL() internal view override returns (string memory) {
return sRedeemURL;
}

function _brandName() internal view override returns (string memory) {
return sBrandName;
}
}
21 changes: 21 additions & 0 deletions test/concrete/PriceOracleV2TestImpl.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: LicenseRef-DCL-1.0
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity =0.8.25;

import {PriceOracleV2} from "src/abstract/PriceOracleV2.sol";

contract PriceOracleV2TestImpl is PriceOracleV2 {
uint256 internal sPrice;

constructor(uint256 price) {
sPrice = price;
}

function _price() internal view override returns (uint256) {
return sPrice;
}

function setPrice(uint256 price) external {
sPrice = price;
}
}
12 changes: 12 additions & 0 deletions test/concrete/TestOwnerFreezable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: LicenseRef-DCL-1.0
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity =0.8.25;

import {OwnerFreezable} from "src/abstract/OwnerFreezable.sol";

contract TestOwnerFreezable is OwnerFreezable {
constructor() {
__OwnerFreezable_init();
_transferOwnership(msg.sender);
}
}
11 changes: 1 addition & 10 deletions test/concrete/TestReceiptManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,13 @@ pragma solidity =0.8.25;

import {IReceiptV3} from "src/interface/IReceiptV3.sol";
import {IReceiptManagerV2} from "src/interface/IReceiptManagerV2.sol";
import {TestReceiptManagerAsset} from "test/concrete/TestReceiptManagerAsset.sol";

/// Thrown when a transfer is not authorized.
/// @param from The transfer attempted from this address.
/// @param to The transfer attemped to this address.
error UnauthorizedTransfer(address from, address to);

contract TestReceiptManagerAsset {
function symbol() external pure returns (string memory) {
return "TRMAsset";
}

function name() external pure returns (string memory) {
return "TestReceiptManagerAsset";
}
}

/// @title TestReceiptManager
/// @notice TEST contract that can be the manager of an `IReceiptV3` and forward
/// function calls to the manager restricted functions on the receipt. Completely
Expand Down
17 changes: 17 additions & 0 deletions test/concrete/TestReceiptManagerAsset.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: LicenseRef-DCL-1.0
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity =0.8.25;

/// @title TestReceiptManagerAsset
/// @notice TEST asset contract that exposes a `symbol` and `name` for use as the
/// underlying asset of a `TestReceiptManager`. Intended for use only by the test
/// harness to drive tests.
contract TestReceiptManagerAsset {
function symbol() external pure returns (string memory) {
return "TRMAsset";
}

function name() external pure returns (string memory) {
return "TestReceiptManagerAsset";
}
}
9 changes: 1 addition & 8 deletions test/src/abstract/OwnerFreezable.ownerFreezeUntil.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
pragma solidity =0.8.25;

import {OwnerFreezableOwnerFreezeUntilTest} from "test/abstract/OwnerFreezableOwnerFreezeUntilTest.t.sol";
import {OwnerFreezable} from "src/abstract/OwnerFreezable.sol";

contract TestOwnerFreezable is OwnerFreezable {
constructor() {
__OwnerFreezable_init();
_transferOwnership(msg.sender);
}
}
import {TestOwnerFreezable} from "test/concrete/TestOwnerFreezable.sol";

contract OwnerFreezableTestOwnerFreezeUntil is OwnerFreezableOwnerFreezeUntilTest {
constructor() {
Expand Down
18 changes: 1 addition & 17 deletions test/src/abstract/PriceOracleV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
pragma solidity =0.8.25;

import {PriceOracleV2} from "src/abstract/PriceOracleV2.sol";
import {Test} from "forge-std-1.16.1/src/Test.sol";

contract PriceOracleV2TestImpl is PriceOracleV2 {
uint256 internal sPrice;

constructor(uint256 price) {
sPrice = price;
}

function _price() internal view override returns (uint256) {
return sPrice;
}

function setPrice(uint256 price) external {
sPrice = price;
}
}
import {PriceOracleV2TestImpl} from "test/concrete/PriceOracleV2TestImpl.sol";

contract PriceOracleV2Test is Test {
address constant ALICE = address(uint160(uint256(keccak256("ALICE"))));
Expand Down
68 changes: 1 addition & 67 deletions test/src/concrete/receipt/ERC20PriceOracleReceipt.metadata.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,73 +19,7 @@ import {
CMASK_BACKSLASH
} from "rain-string-0.2.0/src/lib/parse/LibParseCMask.sol";
import {IERC20Metadata} from "@openzeppelin-contracts-5.6.1/token/ERC20/extensions/IERC20Metadata.sol";

/// This contract is used to test the metadata of the `Receipt` contract.
/// As all the overridden functions are internal, we need to create a new
/// contract that inherits from `Receipt` and exposes these functions; we can't
/// just mock `Receipt`.
contract MutableMetadataReceipt is ERC20PriceOracleReceipt {
string internal sVaultShareSymbol;
string internal sVaultAssetSymbol;
//forge-lint: disable-next-line(mixed-case-variable)
string internal sReceiptSVGURI;
string internal sReferenceAssetSymbol;
//forge-lint: disable-next-line(mixed-case-variable)
string internal sRedeemURL;
string internal sBrandName;

function setVaultShareSymbol(string memory vaultShareSymbol) external {
sVaultShareSymbol = vaultShareSymbol;
}

function setVaultAssetSymbol(string memory vaultAssetSymbol) external {
sVaultAssetSymbol = vaultAssetSymbol;
}

//forge-lint: disable-next-line(mixed-case-function,mixed-case-variable)
function setReceiptSVGURI(string memory receiptSVGURI) external {
sReceiptSVGURI = receiptSVGURI;
}

function setReferenceAssetSymbol(string memory referenceAssetSymbol) external {
sReferenceAssetSymbol = referenceAssetSymbol;
}

//forge-lint: disable-next-line(mixed-case-function,mixed-case-variable)
function setRedeemURL(string memory redeemURL) external {
sRedeemURL = redeemURL;
}

function setBrandName(string memory brandName) external {
sBrandName = brandName;
}

function _vaultShareSymbol() internal view override returns (string memory) {
return sVaultShareSymbol;
}

function _vaultAssetSymbol() internal view override returns (string memory) {
return sVaultAssetSymbol;
}

//forge-lint: disable-next-line(mixed-case-function)
function _receiptSVGURI() internal view override returns (string memory) {
return sReceiptSVGURI;
}

function _referenceAssetSymbol() internal view override returns (string memory) {
return sReferenceAssetSymbol;
}

//forge-lint: disable-next-line(mixed-case-function)
function _redeemURL() internal view override returns (string memory) {
return sRedeemURL;
}

function _brandName() internal view override returns (string memory) {
return sBrandName;
}
}
import {MutableMetadataReceipt} from "test/concrete/MutableMetadataReceipt.sol";

contract ERC20PriceOracleReceiptMetadataTest is ReceiptFactoryTest {
function testReceiptURIZeroError() external {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,8 @@ import {
CertifyStateChange
} from "src/concrete/vault/OffchainAssetReceiptVault.sol";
import {LibExtrospectERC1167Proxy} from "rain-extrospection-0.1.1/src/lib/LibExtrospectERC1167Proxy.sol";
import {IERC165} from "@openzeppelin-contracts-5.6.1/utils/introspection/IERC165.sol";
import {OwnableUpgradeable as Ownable} from "@openzeppelin-contracts-upgradeable-5.6.1/access/OwnableUpgradeable.sol";

contract AlwaysAuthorize is IAuthorizeV1, IERC165 {
/// @inheritdoc IERC165
function supportsInterface(bytes4 interfaceId) external pure override returns (bool) {
return interfaceId == type(IAuthorizeV1).interfaceId || interfaceId == type(IERC165).interfaceId;
}

/// @inheritdoc IAuthorizeV1
function authorize(address, bytes32, bytes memory) external pure override {}
}
import {AlwaysAuthorize} from "test/concrete/AlwaysAuthorize.sol";

contract OffchainAssetReceiptVaultAuthorizeTest is OffchainAssetReceiptVaultTest {
/// Test that authorize contract is as initialized.
Expand Down
Loading