mirror of
https://github.com/3lLobo/zkAuth.git
synced 2026-01-19 17:28:15 -05:00
49 lines
1.8 KiB
Solidity
49 lines
1.8 KiB
Solidity
// SPDX-License-Identifier: GPL-3.0
|
|
|
|
pragma solidity >=0.4.22 <0.9.0;
|
|
|
|
// This import is automatically injected by Remix
|
|
import "remix_tests.sol";
|
|
|
|
// This import is required to use custom transaction context
|
|
// Although it may fail compilation in 'Solidity Compiler' plugin
|
|
// But it will work fine in 'Solidity Unit Testing' plugin
|
|
import "remix_accounts.sol";
|
|
import "../contracts/TotpAuthenticator.sol";
|
|
|
|
// File name has to end with '_test.sol', this file can contain more than one testSuite contracts
|
|
contract testSuite {
|
|
|
|
/// 'beforeAll' runs before all other tests
|
|
/// More special functions are: 'beforeEach', 'beforeAll', 'afterEach' & 'afterAll'
|
|
function beforeAll() public {
|
|
// <instantiate contract>
|
|
Assert.equal(uint(1), uint(1), "1 should be equal to 1");
|
|
}
|
|
|
|
function checkSuccess() public {
|
|
// Use 'Assert' methods: https://remix-ide.readthedocs.io/en/latest/assert_library.html
|
|
Assert.ok(2 == 2, 'should be true');
|
|
Assert.greaterThan(uint(2), uint(1), "2 should be greater than to 1");
|
|
Assert.lesserThan(uint(2), uint(3), "2 should be lesser than to 3");
|
|
}
|
|
|
|
function checkSuccess2() public pure returns (bool) {
|
|
// Use the return value (true or false) to test the contract
|
|
return true;
|
|
}
|
|
|
|
function checkFailure() public {
|
|
Assert.notEqual(uint(1), uint(1), "1 should not be equal to 1");
|
|
}
|
|
|
|
/// Custom Transaction Context: https://remix-ide.readthedocs.io/en/latest/unittesting.html#customization
|
|
/// #sender: account-1
|
|
/// #value: 100
|
|
function checkSenderAndValue() public payable {
|
|
// account index varies 0-9, value is in wei
|
|
Assert.equal(msg.sender, TestsAccounts.getAccount(1), "Invalid sender");
|
|
Assert.equal(msg.value, 100, "Invalid value");
|
|
}
|
|
}
|
|
|