コード例 #1
0
def test_high_threshold(issuer):
    '''threshold too low'''
    with pytest.reverts("dev: treshold > count"):
        issuer.addAuthority([accounts[-1], accounts[-2]], [], 2000000000, 3,
                            {'from': accounts[0]})
    with pytest.reverts("dev: treshold > count"):
        issuer.addAuthority([], [], 2000000000, 1, {'from': accounts[0]})
コード例 #2
0
ファイル: test_reverts.py プロジェクト: zerolawtech/ZAP-Tech
def test_burn_zero(org, share):
    """burn 0 shares"""
    with pytest.reverts("dev: burn 0"):
        share.burn(org, 0, {"from": accounts[0]})
    share.mint(org, 10000, {"from": accounts[0]})
    with pytest.reverts("dev: burn 0"):
        share.burn(org, 0, {"from": accounts[0]})
コード例 #3
0
ファイル: test_reverts.py プロジェクト: zerolawtech/ZAP-Tech
def test_mint_zero(org, share):
    """mint 0 shares"""
    with pytest.reverts("dev: mint 0"):
        share.mint(org, 0, {"from": accounts[0]})
    share.mint(org, 10000, {"from": accounts[0]})
    with pytest.reverts("dev: mint 0"):
        share.mint(org, 0, {"from": accounts[0]})
コード例 #4
0
def test_burn_zero(org, nft):
    """burn 0 nfts"""
    with pytest.reverts("dev: burn 0"):
        nft.burn(1, 1, {"from": accounts[0]})
    nft.mint(org, 10000, 0, "0x00", {"from": accounts[0]})
    with pytest.reverts("dev: burn 0"):
        nft.burn(1, 1, {"from": accounts[0]})
コード例 #5
0
def test_mint_zero(org, nft):
    """mint 0 shares"""
    with pytest.reverts("dev: mint 0"):
        nft.mint(org, 0, 0, "0x00", {"from": accounts[0]})
    nft.mint(org, 10000, 0, "0x00", {"from": accounts[0]})
    with pytest.reverts("dev: mint 0"):
        nft.mint(org, 0, 0, "0x00", {"from": accounts[0]})
コード例 #6
0
def _multisig(org, fn, *args):
    id1 = org.getID(accounts[-6])
    args = list(args) + [{"from": accounts[-6]}]
    # check for failed call, no permission
    with pytest.reverts("dev: not permitted"):
        fn(*args)
    # give permission and check for successful call
    org.setAuthoritySignatures(id1, [fn.signature], True,
                               {"from": accounts[0]})
    assert "MultiSigCallApproved" in fn(*args).events
    rpc.revert()
    # give permission, threhold to 3, check for success and fails
    org.setAuthoritySignatures(id1, [fn.signature], True,
                               {"from": accounts[0]})
    org.setAuthorityThreshold(id1, 3, {"from": accounts[0]})
    args[-1]["from"] = accounts[-6]
    assert "MultiSigCallApproved" not in fn(*args).events
    with pytest.reverts("dev: repeat caller"):
        fn(*args)
    args[-1]["from"] = accounts[-5]
    assert "MultiSigCallApproved" not in fn(*args).events
    with pytest.reverts("dev: repeat caller"):
        fn(*args)
    args[-1]["from"] = accounts[-4]
    assert "MultiSigCallApproved" in fn(*args).events
コード例 #7
0
def _multisig(issuer, fn, *args):
    auth_id = issuer.getID(accounts[3])
    args = list(args) + [{'from': accounts[3]}]
    # check for failed call, no permission
    with pytest.reverts("dev: not permitted"):
        fn(*args)
    # give permission and check for successful call
    issuer.setAuthoritySignatures(auth_id, [fn.signature], True,
                                  {'from': accounts[0]})
    assert 'MultiSigCallApproved' in fn(*args).events
    rpc.revert()
    # give permission, threhold to 3, check for success and fails
    issuer.setAuthoritySignatures(auth_id, [fn.signature], True,
                                  {'from': accounts[0]})
    issuer.setAuthorityThreshold(auth_id, 3, {'from': accounts[0]})
    args[-1]['from'] = accounts[3]
    assert 'MultiSigCallApproved' not in fn(*args).events
    with pytest.reverts("dev: repeat caller"):
        fn(*args)
    args[-1]['from'] = accounts[4]
    assert 'MultiSigCallApproved' not in fn(*args).events
    with pytest.reverts("dev: repeat caller"):
        fn(*args)
    args[-1]['from'] = accounts[5]
    assert 'MultiSigCallApproved' in fn(*args).events
コード例 #8
0
def test_update_member_unknown_id(ikyc, org):
    """update member - unknown ID"""
    oid = org.ownerID()
    with pytest.reverts("dev: unknown ID"):
        ikyc.updateMember("0x1234", 1, 1, 9999999999, {"from": accounts[0]})
    with pytest.reverts("dev: unknown ID"):
        ikyc.updateMember(oid, 1, 1, 9999999999, {"from": accounts[0]})
コード例 #9
0
def test_burn_zero(issuer, token):
    '''burn 0 tokens'''
    with pytest.reverts("dev: burn 0"):
        token.burn(issuer, 0, {'from': accounts[0]})
    token.mint(issuer, 10000, {'from': accounts[0]})
    with pytest.reverts("dev: burn 0"):
        token.burn(issuer, 0, {'from': accounts[0]})
コード例 #10
0
def test_mint_zero(issuer, token):
    '''mint 0 tokens'''
    with pytest.reverts("dev: mint 0"):
        token.mint(issuer, 0, {'from': accounts[0]})
    token.mint(issuer, 10000, {'from': accounts[0]})
    with pytest.reverts("dev: mint 0"):
        token.mint(issuer, 0, {'from': accounts[0]})
コード例 #11
0
def test_update_investor_unknown_id(ikyc, issuer):
    '''update investor - unknown ID'''
    oid = issuer.ownerID()
    with pytest.reverts("dev: unknown ID"):
        ikyc.updateInvestor("0x1234", 1, 1, 9999999999, {'from': accounts[0]})
    with pytest.reverts("dev: unknown ID"):
        ikyc.updateInvestor(oid, 1, 1, 9999999999, {'from': accounts[0]})
コード例 #12
0
def test_known_address(org, share, id1):
    """known address"""
    with pytest.reverts("dev: known address"):
        org.addAuthority([accounts[0]], [], 2000000000, 1, {"from": accounts[0]})
    share.mint(accounts[1], 100, {"from": accounts[0]})
    with pytest.reverts("dev: known address"):
        org.addAuthority([accounts[1]], [], 2000000000, 1, {"from": accounts[0]})
コード例 #13
0
def test_mint_overflow(org, nft):
    """mint - overflows"""
    nft.modifyAuthorizedSupply(2**49, {"from": accounts[0]})
    nft.mint(org, (2**48) - 10, 0, "0x00", {"from": accounts[0]})
    with pytest.reverts("dev: overflow"):
        nft.mint(org, 1000, 1, "0x00", {"from": accounts[0]})
    with pytest.reverts("dev: upper bound"):
        nft.mint(org, 9, 1, "0x00", {"from": accounts[0]})
def test_investor_txfrom(token, cust):
    '''Investor transferFrom custodian'''
    token.transfer(accounts[1], 10000, {'from': accounts[0]})
    token.transfer(cust, 10000, {'from': accounts[1]})
    with pytest.reverts("Insufficient allowance"):
        token.transferFrom(cust, accounts[1], 5000, {'from': accounts[1]})
    with pytest.reverts("Insufficient allowance"):
        token.transferFrom(cust, accounts[1], 5000, {'from': accounts[2]})
コード例 #15
0
def test_authority_add_authority_addresses(kyc, owner_id, auth_id):
    """authority cannot add authority addresses"""
    with pytest.reverts("dev: not owner"):
        kyc.registerAddresses(owner_id, (accounts[1], accounts[2]),
                              {"from": accounts[-1]})
    with pytest.reverts("dev: not owner"):
        kyc.registerAddresses(auth_id, (accounts[1], accounts[2]),
                              {"from": accounts[-1]})
コード例 #16
0
def test_already_active(issuer, token, module_issuer, module_token):
    '''attach already active module'''
    issuer.attachModule(token, module_issuer, {'from': accounts[0]})
    with pytest.reverts("dev: already active"):
        issuer.attachModule(token, module_issuer, {'from': accounts[0]})
    issuer.attachModule(token, module_token, {'from': accounts[0]})
    with pytest.reverts("dev: already active"):
        issuer.attachModule(token, module_token, {'from': accounts[0]})
コード例 #17
0
def test_add_twice(issuer, testcust, TestCustodian):
    '''add custodian - already added'''
    issuer.addCustodian(testcust, {'from': accounts[0]})
    with pytest.reverts("dev: known address"):
        issuer.addCustodian(testcust, {'from': accounts[0]})
    c = accounts[1].deploy(TestCustodian)
    with pytest.reverts("dev: known ID"):
        issuer.addCustodian(c, {'from': accounts[0]})
コード例 #18
0
def test_high_threshold(org):
    """threshold too low"""
    with pytest.reverts("dev: treshold > count"):
        org.addAuthority(
            [accounts[-1], accounts[-2]], [], 2000000000, 3, {"from": accounts[0]}
        )
    with pytest.reverts("dev: treshold > count"):
        org.addAuthority([], [], 2000000000, 1, {"from": accounts[0]})
コード例 #19
0
def test_already_active(org, share, module_org, module_share):
    """attach already active module"""
    org.attachModule(share, module_org, {"from": accounts[0]})
    with pytest.reverts("dev: already active"):
        org.attachModule(share, module_org, {"from": accounts[0]})
    org.attachModule(share, module_share, {"from": accounts[0]})
    with pytest.reverts("dev: already active"):
        org.attachModule(share, module_share, {"from": accounts[0]})
コード例 #20
0
def test_member_txfrom(nft, cust):
    """Member transferFrom custodian"""
    nft.transfer(accounts[1], 10000, {"from": accounts[0]})
    nft.transfer(cust, 10000, {"from": accounts[1]})
    with pytest.reverts("Insufficient allowance"):
        nft.transferFrom(cust, accounts[1], 5000, {"from": accounts[1]})
    with pytest.reverts("Insufficient allowance"):
        nft.transferFrom(cust, accounts[1], 5000, {"from": accounts[2]})
コード例 #21
0
def test_add_twice(org, testcust, TestCustodian):
    """add custodian - already added"""
    org.addCustodian(testcust, {"from": accounts[0]})
    with pytest.reverts("dev: known address"):
        org.addCustodian(testcust, {"from": accounts[0]})
    c = accounts[1].deploy(TestCustodian)
    with pytest.reverts("dev: known ID"):
        org.addCustodian(c, {"from": accounts[0]})
コード例 #22
0
def test_update_member_authority_country(kyc, auth_id):
    """update member - authority country permission"""
    with pytest.reverts("dev: country"):
        kyc.updateMember("0x1111", 1, 1, 9999999999, {"from": accounts[-1]})
    kyc.setAuthorityCountries(auth_id, (1, ), True, {"from": accounts[0]})
    kyc.updateMember("0x1111", 1, 1, 9999999999, {"from": accounts[-1]}),
    kyc.setAuthorityCountries(auth_id, (1, ), False, {"from": accounts[0]})
    with pytest.reverts("dev: country"):
        kyc.updateMember("0x1111", 1, 1, 9999999999, {"from": accounts[-1]})
コード例 #23
0
def test_not_enough_options(options, id1, issueoptions, sleep):
    """insufficient vested options"""
    issueoptions(id1, 10)
    sleep(3)
    with pytest.reverts("Insufficient vested options"):
        options.exerciseOptions(10, 400, {"from": accounts[1], "amount": 4000})
    options.exerciseOptions(10, 200, {"from": accounts[1], "amount": 2000})
    with pytest.reverts("Insufficient vested options"):
        options.exerciseOptions(10, 100, {"from": accounts[1], "amount": 1000})
コード例 #24
0
def test_known_address(issuer, token, id1):
    '''known address'''
    with pytest.reverts("dev: known address"):
        issuer.addAuthority([accounts[0]], [], 2000000000, 1,
                            {'from': accounts[0]})
    token.mint(accounts[1], 100, {'from': accounts[0]})
    with pytest.reverts("dev: known address"):
        issuer.addAuthority([accounts[1]], [], 2000000000, 1,
                            {'from': accounts[0]})
コード例 #25
0
def test_transferFrom_reverts(hkdai, accounts):
    '''transferFrom should revert'''
    with pytest.reverts("Insufficient allowance"):
        hkdai.transferFrom(accounts[0], accounts[2], "1 ether",
                           {'from': accounts[1]})

    with pytest.reverts("Insufficient allowance"):
        hkdai.transferFrom(accounts[0], accounts[2], "1 ether",
                           {'from': accounts[0]})
コード例 #26
0
def test_add_known(org, id1):
    """add known addresses"""
    org.addAuthorityAddresses(id1, accounts[-10:-7], {"from": accounts[0]})
    with pytest.reverts("dev: known address"):
        org.addAuthorityAddresses(id1, accounts[-9:-6], {"from": accounts[0]})
    with pytest.reverts("dev: known address"):
        org.addAuthorityAddresses(id1,
                                  (accounts[-6], accounts[-5], accounts[-6]),
                                  {"from": accounts[0]})
コード例 #27
0
def test_update_investor_authority_country(kyc, auth_id):
    '''update investor - authority country permission'''
    with pytest.reverts("dev: country"):
        kyc.updateInvestor("0x1111", 1, 1, 9999999999, {'from': accounts[-1]})
    kyc.setAuthorityCountries(auth_id, (1, ), True, {'from': accounts[0]})
    kyc.updateInvestor("0x1111", 1, 1, 9999999999, {'from': accounts[-1]}),
    kyc.setAuthorityCountries(auth_id, (1, ), False, {'from': accounts[0]})
    with pytest.reverts("dev: country"):
        kyc.updateInvestor("0x1111", 1, 1, 9999999999, {'from': accounts[-1]})
コード例 #28
0
def test_set_authority_unknown_id(kyc, auth_id):
    '''set investor authority - unknown id'''
    id_ = kyc.getAuthorityID(accounts[0])
    with pytest.reverts("dev: unknown ID"):
        kyc.setInvestorAuthority(id_, (auth_id, ), {'from': accounts[0]})
    with pytest.reverts("dev: unknown ID"):
        kyc.setInvestorAuthority(auth_id, (id_, ), {'from': accounts[0]})
    with pytest.reverts("dev: unknown ID"):
        kyc.setInvestorAuthority(id_, ("0x1234", ), {'from': accounts[0]})
コード例 #29
0
def test_restrict_wrong_ID(ikyc):
    """cannot restrict - wrong ID"""
    ikyc.addMember(
        "0x123456", 1, 1, 1, 9999999999, (accounts[6],), {"from": accounts[0]}
    )
    with pytest.reverts("dev: wrong ID"):
        ikyc.restrictAddresses(id_, (accounts[6],), {"from": accounts[0]})
    with pytest.reverts("dev: wrong ID"):
        ikyc.restrictAddresses("0x123456", (accounts[2],), {"from": accounts[0]})
コード例 #30
0
def test_set_authority_unknown_id(kyc, auth_id):
    """set member authority - unknown id"""
    id_ = kyc.getAuthorityID(accounts[0])
    with pytest.reverts("dev: unknown ID"):
        kyc.setMemberAuthority(id_, (auth_id, ), {"from": accounts[0]})
    with pytest.reverts("dev: unknown ID"):
        kyc.setMemberAuthority(auth_id, (id_, ), {"from": accounts[0]})
    with pytest.reverts("dev: unknown ID"):
        kyc.setMemberAuthority(id_, ("0x1234", ), {"from": accounts[0]})