Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(scale): Added a scale test with benchmarks #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion lang10/contracts/auction.sympl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ schema Admin:
###################################
# Auction API and Implementations #
###################################

# Returns all auctions in storage.
@clientside
def get_auctions() -> List[Auction]:
Expand Down
59 changes: 59 additions & 0 deletions lang10/scale_tests/auctions_scale_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import pytest
import time
from assembly_client.api.contracts import ContractRef

AUCTION = ContractRef('auction', '1.0.0', 10)

name_str = "stamps collection #{index}"
price_str="{price}"
i = 0

def do_an_auction(auction, key_alias, bidder, second_bidder, other_key_alias, third_key_alias):
new_auction = auction.create_auction(product_description='stamps collection',
initial_price='100',
silent=True)
auction.add_member(new_member=third_key_alias, id=new_auction['id'])
auction.add_member(new_member=other_key_alias, id=new_auction['id'])
max_n = 20
for idx in range(1, max_n):
bidder.bid(id=new_auction['id'], amount=price_str.format(price=100+idx))
for idx in range(max_n+2, max_n*2):
second_bidder.bid(id=new_auction['id'], amount=price_str.format(price=100+idx))
winning_bid = auction.close_auction(id=new_auction['id'])
assert winning_bid['amount'] == price_str.format(price=100 + (max_n*2) -1)

class TestScaleAuction():

@pytest.fixture
def reset_publish(self, network):
network.reset(sympl_version=10)
network.publish([AUCTION])

@pytest.fixture
def key_alias(self, network):
return network.register_key_alias()

@pytest.fixture
def other_key_alias(self, network):
return network.register_key_alias()

@pytest.fixture
def third_key_alias(self, network):
return network.register_key_alias()

@pytest.fixture
def auction(self, network, reset_publish, key_alias):
return network[key_alias].auction['10-1.0.0']

@pytest.fixture
def bidder(self, network, reset_publish, other_key_alias):
return network[other_key_alias].auction['10-1.0.0']

@pytest.fixture
def second_bidder(self, network, reset_publish, third_key_alias):
return network[third_key_alias].auction['10-1.0.0']

#### Scale auction tests
def test_scale_auctions_creation(self, auction, key_alias, bidder, second_bidder, other_key_alias, third_key_alias, benchmark):
auction.create_admin(new_admin=key_alias)
benchmark.pedantic(do_an_auction, args=(auction, key_alias, bidder, second_bidder, other_key_alias, third_key_alias), iterations=3, rounds=3)