How to use test_create_token method in tempest

Best Python code snippet using tempest_python

ERC1155TLCore_test.py

Source:ERC1155TLCore_test.py Github

copy

Full Screen

...83 def test_payout(self, contract, admin, payout):84 assert contract.payoutAddress() == payout.address85class TestNonOwnerAdminNoAccess:86 revertStr = "ERC1155TLCore: Address not admin or owner"87 def test_create_token(self, contract, token0):88 with brownie.reverts(self.revertStr):89 contract.createToken(*token0, {"from": a[4]})90 def test_set_mint_allowance(self, contract):91 with brownie.reverts(self.revertStr):92 contract.setMintAllowance(0, 1, {"from": a[4]})93 def test_freeze_token(self, contract):94 with brownie.reverts(self.revertStr):95 contract.freezeToken(0, {"from": a[4]})96 def test_set_uri(self, contract):97 with brownie.reverts(self.revertStr):98 contract.setURI(0, "test", {"from": a[4]})99 def test_set_mint_status(self, contract):100 with brownie.reverts(self.revertStr):101 contract.setMintStatus(0, True, {"from": a[4]})102 def test_airdrop(self, contract):103 with brownie.reverts(self.revertStr):104 contract.airdrop(0, [a[4].address]*3, {"from": a[4]})105 def test_owner_mint(self, contract):106 with brownie.reverts(self.revertStr):107 contract.ownerMint(0, 5, {"from": a[4]})108 def test_withdraw_erc20(self, contract, token):109 with brownie.reverts(self.revertStr):110 contract.withdrawERC20(token.address, token.balanceOf(contract.address), {"from": a[4]})111 def test_withdraw_ether(self, contract):112 with brownie.reverts(self.revertStr):113 contract.withdrawEther(contract.balance(), {"from": a[4]})114class TestNonAdminAccess:115 def test_renounce_admin_user(self, contract):116 with brownie.reverts("ERC1155TLCore: Address not admin"):117 contract.renounceAdmin({"from": a[4]})118 def test_renounce_admin_owner(self, contract, owner):119 with brownie.reverts("ERC1155TLCore: Address not admin"):120 contract.renounceAdmin({"from": owner})121class TestNonOwnerNoAccess:122 revertStr = "Ownable: caller is not the owner"123 def test_set_royalty_recipient_user(self, contract):124 with brownie.reverts(self.revertStr):125 contract.setRoyaltyRecipient(0, a[4].address, {"from": a[4]})126 def test_set_royalty_percentage_user(self, contract):127 with brownie.reverts(self.revertStr):128 contract.setRoyaltyPercentage(0, 1000, {"from": a[4]})129 def test_set_royalty_recipient_admin(self, contract, admin):130 with brownie.reverts(self.revertStr):131 contract.setRoyaltyRecipient(0, a[4].address, {"from": admin})132 def test_set_royalty_percentage_admin(self, contract, admin):133 with brownie.reverts(self.revertStr):134 contract.setRoyaltyPercentage(0, 1000, {"from": admin})135 def test_set_admin_address_user(self, contract):136 with brownie.reverts(self.revertStr):137 contract.setAdminAddress(a[4].address, {"from": a[4]})138 def test_set_admin_address_admin(self, contract, admin):139 with brownie.reverts(self.revertStr):140 contract.setAdminAddress(a[4].address, {"from": admin})141 def test_set_payout_address_user(self, contract):142 with brownie.reverts(self.revertStr):143 contract.setPayoutAddress(a[4].address, {"from": a[4]})144 def test_set_payout_address_admin(self, contract, admin):145 with brownie.reverts(self.revertStr):146 contract.setPayoutAddress(a[4].address, {"from": admin})147class TestAdminAccess:148 def test_create_token(self, contract, admin, token0):149 contract.createToken(*token0, {"from": admin})150 supply = contract.getTokenSupply(0)151 allowance = contract.getMintAllowance(0)152 status = contract.getMintStatus(0)153 price = contract.getTokenPrice(0)154 root = contract.getMerkleRoot(0)155 [recp, amt] = contract.royaltyInfo(0, Wei("1 ether"))156 uri = contract.uri(0)157 assert [0, supply, status, allowance, price, uri, root, recp, amt*10000/Wei("1 ether")] == token0158 def test_duplicate_token(self, contract, admin, token0):159 with brownie.reverts("ERC1155TLCore: Token ID already exists"):160 contract.createToken(*token0, {"from": admin})161 def test_set_mint_allowance(self, contract, admin):162 contract.setMintAllowance(0, 1, {"from": admin})163 assert contract.getMintAllowance(0) == 1164 def test_set_uri(self, contract, admin):165 contract.setURI(0, "test", {"from": admin})166 assert contract.uri(0) == "test"167 def test_freeze_token(self, contract, admin):168 contract.freezeToken(0, {"from": admin})169 with brownie.reverts("ERC1155TLCore: Token metadata frozen"):170 contract.setURI(0, "tests", {"from": admin})171 def test_set_mint_status(self, contract, admin):172 contract.setMintStatus(0, True, {"from": admin})173 assert contract.getMintStatus(0)174 def test_airdrop(self, contract, admin):175 contract.airdrop(0, [admin.address]*3, {"from": admin})176 assert contract.balanceOf(admin.address, 0) == 3177 def test_owner_mint(self, contract, admin, owner):178 contract.ownerMint(0, 5, {"from": admin})179 assert contract.balanceOf(owner.address, 0) == 5180 def test_withdraw_erc20(self, contract, admin, token):181 contract.withdrawERC20(token.address, token.balanceOf(contract.address), {"from": admin})182 def test_withdraw_ether(self, contract, admin):183 contract.withdrawEther(contract.balance(), {"from": admin})184 def test_renounce_admin(self, contract, admin):185 contract.renounceAdmin({"from": admin})186 assert contract.adminAddress() == f"0x{bytes(20).hex()}"187class TestOwnerAccess:188 def test_create_token(self, contract, owner, token1):189 contract.createToken(*token1, {"from": owner})190 supply = contract.getTokenSupply(1)191 allowance = contract.getMintAllowance(1)192 status = contract.getMintStatus(1)193 price = contract.getTokenPrice(1)194 root = contract.getMerkleRoot(1)195 [recp, amt] = contract.royaltyInfo(1, Wei("1 ether"))196 uri = contract.uri(1)197 assert [1, supply, status, allowance, price, uri, root, recp, amt*10000/Wei("1 ether")] == token1198 def test_duplicate_token(self, contract, owner, token1):199 with brownie.reverts("ERC1155TLCore: Token ID already exists"):200 contract.createToken(*token1, {"from": owner})201 def test_set_mint_allowance(self, contract, owner):202 contract.setMintAllowance(1, 1, {"from": owner})203 assert contract.getMintAllowance(1) == 1204 def test_set_uri(self, contract, owner):205 contract.setURI(1, "test", {"from": owner})206 assert contract.uri(1) == "test"207 def test_freeze_token(self, contract, owner):208 contract.freezeToken(1, {"from": owner})209 with brownie.reverts("ERC1155TLCore: Token metadata frozen"):210 contract.setURI(1, "tests", {"from": owner})211 def test_set_mint_status(self, contract, owner):212 contract.setMintStatus(1, True, {"from": owner})213 assert contract.getMintStatus(1)214 def test_set_royalty_recipient(self, contract, owner, admin):215 contract.setRoyaltyRecipient(1, admin.address, {"from": owner})216 [recp, amt] = contract.royaltyInfo(1, Wei("1 ether"))217 assert recp == admin.address218 def test_set_royalty_percentage(self, contract, owner):219 contract.setRoyaltyPercentage(1, 1000, {"from": owner})220 [recp, amt] = contract.royaltyInfo(1, Wei("1 ether"))221 assert amt == Wei(f"{1000/10000} ether")222 def test_set_admin_address(self, contract, owner):223 contract.setAdminAddress(a[4].address, {"from": owner})224 assert contract.adminAddress() == a[4].address225 def test_set_payout_address(self, contract, owner):226 contract.setPayoutAddress(a[5].address, {"from": owner})227 assert contract.payoutAddress() == a[5].address228 def test_airdrop(self, contract, admin, owner):229 contract.airdrop(1, [admin.address]*3, {"from": owner})230 assert contract.balanceOf(admin.address, 1) == 3231 def test_owner_mint(self, contract, admin, owner):232 contract.ownerMint(1, 5, {"from": owner})233 assert contract.balanceOf(owner.address, 1) == 5234 def test_withdraw_erc20(self, contract, owner, token):235 contract.withdrawERC20(token.address, token.balanceOf(contract.address), {"from": owner})236 def test_withdraw_ether(self, contract, owner):237 contract.withdrawEther(contract.balance(), {"from": owner})238class TestNonExistentTokenId:239 revertStr = "ERC1155TLCore: Token ID not valid"240 def test_set_mint_allowance(self, contract, admin):241 with brownie.reverts(self.revertStr):242 contract.setMintAllowance(0, 1, {"from": admin})243 def test_freeze_token(self, contract, admin):244 with brownie.reverts(self.revertStr):245 contract.freezeToken(0, {"from": admin})246 def test_set_uri(self, contract, admin):247 with brownie.reverts(self.revertStr):248 contract.setURI(0, "test", {"from": admin})249 def test_set_mint_status(self, contract, admin):250 with brownie.reverts(self.revertStr):251 contract.setMintStatus(0, True, {"from": admin})252 def test_set_royalty_recipient(self, contract, owner):253 with brownie.reverts(self.revertStr):254 contract.setRoyaltyRecipient(0, owner.address, {"from": owner})255 def test_set_royalty_percentage(self, contract, owner):256 with brownie.reverts(self.revertStr):257 contract.setRoyaltyPercentage(0, 1000, {"from": owner})258 def test_airdrop(self, contract, admin):259 with brownie.reverts(self.revertStr):260 contract.airdrop(0, [admin.address]*3, {"from": admin})261 def test_owner_mint(self, contract, admin):262 with brownie.reverts(self.revertStr):263 contract.ownerMint(0, 5, {"from": admin})264 def test_mint(self, contract):265 with brownie.reverts(self.revertStr):266 contract.mint(0, 5, [], {"from": a[4]})267class TestToken0:268 def test_create_token(self, contract, admin, token0):269 contract.createToken(*token0, {"from": admin})270 supply = contract.getTokenSupply(0)271 allowance = contract.getMintAllowance(0)272 status = contract.getMintStatus(0)273 price = contract.getTokenPrice(0)274 root = contract.getMerkleRoot(0)275 [recp, amt] = contract.royaltyInfo(0, Wei("1 ether"))276 uri = contract.uri(0)277 assert [0, supply, status, allowance, price, uri, root, recp, amt*10000/Wei("1 ether")] == token0278 def test_mint(self, contract):279 with brownie.reverts("ERC1155TLCore: Mint not open"):280 contract.mint(0, 1, [], {"from": a[4]})281 def test_airdrop(self, contract, admin, token0):282 contract.airdrop(0, a[4:10], {"from": admin})283 assert contract.balanceOf(a[4].address, 0) == 1 and contract.balanceOf(a[5].address, 0) == 1 and contract.balanceOf(a[6].address, 0) == 1 \284 and contract.balanceOf(a[7].address, 0) == 1 and contract.balanceOf(a[8].address, 0) == 1 and contract.balanceOf(a[9].address, 0) == 1 \285 and contract.getTokenSupply(0) == token0[1] - 6286 287 def test_owner_mint(self, contract, admin, owner, token0):288 contract.ownerMint(0, token0[1] - 6, {"from": admin})289 assert contract.balanceOf(owner.address, 0) == token0[1] - 6 and contract.getTokenSupply(0) == 0290 def test_airdrop_no_supply(self, contract, admin):291 with brownie.reverts("ERC1155TLCore: Not enough token supply available"):292 contract.airdrop(0, [a[4].address]*3, {"from": admin})293 def test_owner_mint_no_supply(self, contract, admin):294 with brownie.reverts("ERC1155TLCore: Not enough token supply available"):295 contract.ownerMint(0, 3, {"from": admin})296 297 def test_mint_no_supply(self, contract):298 with brownie.reverts("ERC1155TLCore: Not enough token supply available"):299 contract.mint(0, 1, [], {"from": a[4]})300class TestToken1:301 def test_create_token(self, contract, admin, token1):302 contract.createToken(*token1, {"from": admin})303 supply = contract.getTokenSupply(1)304 allowance = contract.getMintAllowance(1)305 status = contract.getMintStatus(1)306 price = contract.getTokenPrice(1)307 root = contract.getMerkleRoot(1)308 [recp, amt] = contract.royaltyInfo(1, Wei("1 ether"))309 uri = contract.uri(1)310 assert [1, supply, status, allowance, price, uri, root, recp, amt*10000/Wei("1 ether")] == token1311 def test_mint_not_open(self, contract):312 with brownie.reverts("ERC1155TLCore: Mint not open"):313 contract.mint(1, 1, [], {"from": a[4]})314 def test_mint_no_ether(self, contract, admin):315 contract.setMintStatus(1, True, {"from": admin})316 with brownie.reverts("ERC1155TLCore: Not enough ether attached to the transaction"):317 contract.mint(1, 1, merkleProofs[0][0], {"from": a[4]})318 def test_mint(self, contract, token1):319 contract.mint(1, 1, merkleProofs[0][0], {"from": a[4], "value": token1[4]})320 contract.mint(1, 1, merkleProofs[0][1], {"from": a[5], "value": token1[4]})321 contract.mint(1, 1, merkleProofs[0][2], {"from": a[6], "value": token1[4]})322 assert contract.balanceOf(a[4].address, 1) == 1 and contract.balanceOf(a[5].address, 1) == 1 and contract.balanceOf(a[6].address, 1) == 1323 def test_mint_allowance_reached(self, contract, token1):324 with brownie.reverts("ERC1155TLCore: Cannot mint more than allowed"):325 contract.mint(1, 1, merkleProofs[0][0], {"from": a[4], "value": token1[4]})326 327 def test_mint_not_on_allowlist(self, contract, token1):328 with brownie.reverts("ERC1155TLCore: Not on allowlist"):329 contract.mint(1, 1, [], {"from": a[7], "value": token1[4]})330 def test_mint_again(self, contract, token1, admin):331 contract.setMintAllowance(1, 2, {"from": admin})332 contract.mint(1, 1, merkleProofs[0][0], {"from": a[4], "value": token1[4]})333 contract.mint(1, 1, merkleProofs[0][1], {"from": a[5], "value": token1[4]})334 contract.mint(1, 1, merkleProofs[0][2], {"from": a[6], "value": token1[4]})335 assert contract.balanceOf(a[4].address, 1) == 2 and contract.balanceOf(a[5].address, 1) == 2 and contract.balanceOf(a[6].address, 1) == 2336 def test_mint_no_supply(self, contract, token1):337 with brownie.reverts("ERC1155TLCore: Not enough token supply available"):338 contract.mint(1, 5, [], {"from": a[4], "value": token1[4]*5})339 340 def test_owner_mint(self, contract, admin, owner, token1):341 contract.ownerMint(1, token1[1] - 6, {"from": admin})342 assert contract.balanceOf(owner.address, 1) == token1[1] - 6 and contract.getTokenSupply(1) == 0343 def test_airdrop_no_supply(self, contract, admin):344 with brownie.reverts("ERC1155TLCore: Not enough token supply available"):345 contract.airdrop(1, [a[4].address]*3, {"from": admin})346 def test_owner_mint_no_supply(self, contract, admin):347 with brownie.reverts("ERC1155TLCore: Not enough token supply available"):348 contract.ownerMint(1, 3, {"from": admin})349class TestToken2:350 def test_create_token(self, contract, admin, token2):351 contract.createToken(*token2, {"from": admin})352 supply = contract.getTokenSupply(2)353 allowance = contract.getMintAllowance(2)354 status = contract.getMintStatus(2)355 price = contract.getTokenPrice(2)356 root = contract.getMerkleRoot(2)357 [recp, amt] = contract.royaltyInfo(2, Wei("1 ether"))358 uri = contract.uri(2)359 assert [2, supply, status, allowance, price, uri, root, recp, amt*10000/Wei("1 ether")] == token2360 def test_mint_not_open(self, contract):361 with brownie.reverts("ERC1155TLCore: Mint not open"):362 contract.mint(2, 1, [], {"from": a[7]})363 def test_mint_no_ether(self, contract, admin):364 contract.setMintStatus(2, True, {"from": admin})365 with brownie.reverts("ERC1155TLCore: Not enough ether attached to the transaction"):366 contract.mint(2, 1, merkleProofs[1][0], {"from": a[7]})367 def test_mint(self, contract, token2):368 contract.mint(2, 1, merkleProofs[1][0], {"from": a[7], "value": token2[4]})369 contract.mint(2, 1, merkleProofs[1][1], {"from": a[8], "value": token2[4]})370 contract.mint(2, 1, merkleProofs[1][2], {"from": a[9], "value": token2[4]})371 assert contract.balanceOf(a[7].address, 2) == 1 and contract.balanceOf(a[8].address, 2) == 1 and contract.balanceOf(a[9].address, 2) == 1372 def test_mint_allowance_reached(self, contract, token2):373 with brownie.reverts("ERC1155TLCore: Cannot mint more than allowed"):374 contract.mint(2, 1, merkleProofs[1][0], {"from": a[7], "value": token2[4]})375 376 def test_mint_not_on_allowlist(self, contract, token2):377 with brownie.reverts("ERC1155TLCore: Not on allowlist"):378 contract.mint(2, 1, [], {"from": a[4], "value": token2[4]})379 def test_mint_again(self, contract, token2, admin):380 contract.setMintAllowance(2, 2, {"from": admin})381 contract.mint(2, 1, merkleProofs[1][0], {"from": a[7], "value": token2[4]})382 contract.mint(2, 1, merkleProofs[1][1], {"from": a[8], "value": token2[4]})383 contract.mint(2, 1, merkleProofs[1][2], {"from": a[9], "value": token2[4]})384 assert contract.balanceOf(a[7].address, 2) == 2 and contract.balanceOf(a[8].address, 2) == 2 and contract.balanceOf(a[9].address, 2) == 2 \385 and contract.getNumMinted(2, a[7].address) == 2 and contract.getNumMinted(2, a[8].address) == 2 and contract.getNumMinted(2, a[9].address) == 2386 def test_mint_no_supply(self, contract, token2):387 with brownie.reverts("ERC1155TLCore: Not enough token supply available"):388 contract.mint(2, 5, [], {"from": a[7], "value": token2[4]*5})389 390 def test_airdop(self, contract, admin, token2):391 contract.airdrop(2, [admin.address]*(token2[1] - 6), {"from": admin})392 assert contract.balanceOf(admin.address, 2) == token2[1] - 6 and contract.getTokenSupply(2) == 0393 def test_airdrop_no_supply(self, contract, admin):394 with brownie.reverts("ERC1155TLCore: Not enough token supply available"):395 contract.airdrop(2, [a[4].address]*3, {"from": admin})396 def test_owner_mint_no_supply(self, contract, admin):397 with brownie.reverts("ERC1155TLCore: Not enough token supply available"):398 contract.ownerMint(2, 3, {"from": admin})399 def test_withdraw_ether(self, contract, admin, payout):400 init_balance = payout.balance()401 contract_balance = contract.balance()402 contract.withdrawEther(contract.balance(), {"from": admin})403 assert payout.balance() - init_balance == contract_balance404class TestToken3:405 def test_create_token(self, contract, admin, token3):406 contract.createToken(*token3, {"from": admin})407 supply = contract.getTokenSupply(3)408 allowance = contract.getMintAllowance(3)409 status = contract.getMintStatus(3)410 price = contract.getTokenPrice(3)411 root = contract.getMerkleRoot(3)412 [recp, amt] = contract.royaltyInfo(3, Wei("1 ether"))413 uri = contract.uri(3)414 assert [3, supply, status, allowance, price, uri, root, recp, amt*10000/Wei("1 ether")] == token3415 def test_mint_not_open(self, contract):416 with brownie.reverts("ERC1155TLCore: Mint not open"):417 contract.mint(3, 1, [], {"from": a[4]})418 def test_mint_more_than_allowed(self, contract, admin):419 contract.setMintStatus(3, True, {"from": admin})420 with brownie.reverts("ERC1155TLCore: Cannot mint more than allowed"):421 contract.mint(3, 5, [], {"from": a[4]})422 def test_mint_multi(self, contract):423 contract.mint(3, 2, [], {"from": a[4]})424 contract.mint(3, 2, [], {"from": a[5]})425 contract.mint(3, 2, [], {"from": a[6]})426 assert contract.balanceOf(a[4].address, 3) == 2 and contract.balanceOf(a[5].address, 3) == 2 and contract.balanceOf(a[6].address, 3) == 2427 def test_mint_single(self, contract):428 contract.mint(3, 1, [], {"from": a[7]})429 contract.mint(3, 1, [], {"from": a[8]})430 contract.mint(3, 1, [], {"from": a[9]})431 assert contract.balanceOf(a[7].address, 3) == 1 and contract.balanceOf(a[8].address, 3) == 1 and contract.balanceOf(a[9].address, 3) == 1432 def test_mint_again(self, contract):433 contract.mint(3, 1, [], {"from": a[7]})434 assert contract.balanceOf(a[7].address, 3) == 2 and contract.getNumMinted(3, a[7].address) == 2435 def test_mint_no_supply(self, contract):436 with brownie.reverts("ERC1155TLCore: Not enough token supply available"):437 contract.mint(3, 1, [], {"from": a[7]})438 def test_airdrop_no_supply(self, contract, admin):439 with brownie.reverts("ERC1155TLCore: Not enough token supply available"):440 contract.airdrop(3, [a[4].address]*3, {"from": admin})441 def test_owner_mint_no_supply(self, contract, admin):442 with brownie.reverts("ERC1155TLCore: Not enough token supply available"):443 contract.ownerMint(3, 3, {"from": admin})444class TestReentrancy:445 def test_create_token(self, contract, admin, token2):446 t = token2447 t[6] = Web3.toHex(b'')448 contract.createToken(*t, {"from": admin})449 supply = contract.getTokenSupply(2)450 allowance = contract.getMintAllowance(2)451 status = contract.getMintStatus(2)452 price = contract.getTokenPrice(2)453 root = contract.getMerkleRoot(2)454 [recp, amt] = contract.royaltyInfo(2, Wei("1 ether"))455 uri = contract.uri(2)456 assert [2, supply, status, allowance, price, uri, root, recp, amt*10000/Wei("1 ether")] == token2457 def test_airdrop(self, contract, admin):458 reenter = ERC1155TLCoreAirdropReentrancy.deploy(contract.address, 2, {"from": a[4]})459 with brownie.reverts("ERC1155TLCore: Address not admin or owner"):...

Full Screen

Full Screen

test_main.py

Source:test_main.py Github

copy

Full Screen

1from main import create_token2from main import verify_signature3class TestChallenge4:4 token = b'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsYW5ndWFnZSI6IlB5dGhvbiJ9.sM_VQuKZe_VTlqfS3FlAm8XLFhgvQQLk2kkRTpiXq7M'5 def test_create_token(self):6 assert create_token({"language": "Python"}, "acelera") == self.token7 8 def test_verify_signature(self):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful