integration: fix proof parameters for tests

Increased times due to waiting on next period.
Fixed data to be of right size.
Updated expected payout due to hosting 5 slots.
This commit is contained in:
Mark Spanbroek 2024-02-22 07:24:07 +01:00
parent 0aa7590c96
commit 1afa201049
No known key found for this signature in database
GPG Key ID: FBE3E9548D427C00
1 changed files with 16 additions and 19 deletions

View File

@ -175,22 +175,16 @@ twonodessuite "Integration tests", debug1 = false, debug2 = false:
test "nodes negotiate contracts on the marketplace":
let size = 0xFFFFFF.u256
let dataSetSize = 8 * DefaultBlockSize.int
let data = await RandomChunker.example(blocks=8)
# client 2 makes storage available
discard client2.postAvailability(size=size, duration=200.u256, minPrice=300.u256, maxCollateral=300.u256)
let chunker = RandomChunker.new(rng.Rng.instance(), size = dataSetSize, chunkSize = DefaultBlockSize)
var data: seq[byte]
while data.len < dataSetSize:
data.add(await chunker.getBytes())
discard client2.postAvailability(size=size, duration=20*60.u256, minPrice=300.u256, maxCollateral=300.u256)
# client 1 requests storage
let expiry = (await ethProvider.currentTime()) + 120
let cid = client1.upload(string.fromBytes(data)).get
let expiry = (await ethProvider.currentTime()) + 5*60
let cid = client1.upload(data).get
let id = client1.requestStorage(
cid,
duration=180.u256,
duration=10*60.u256,
reward=400.u256,
proofProbability=3.u256,
expiry=expiry,
@ -198,7 +192,7 @@ twonodessuite "Integration tests", debug1 = false, debug2 = false:
nodes = 5,
tolerance = 2).get
check eventually(client1.purchaseStateIs(id, "started"), timeout=120*1000)
check eventually(client1.purchaseStateIs(id, "started"), timeout=5*60*1000)
let purchase = client1.getPurchase(id).get
check purchase.error == none string
let availabilities = client2.getAvailabilities().get
@ -207,19 +201,22 @@ twonodessuite "Integration tests", debug1 = false, debug2 = false:
check newSize > 0 and newSize < size
test "node slots gets paid out":
let size = 0xFFFFFF.u256
let data = await RandomChunker.example(blocks = 8)
let marketplace = Marketplace.new(Marketplace.address, ethProvider.getSigner())
let tokenAddress = await marketplace.token()
let token = Erc20Token.new(tokenAddress, ethProvider.getSigner())
let reward = 400.u256
let duration = 100.u256
let duration = 10*60.u256
let nodes = 5'u
# client 2 makes storage available
let startBalance = await token.balanceOf(account2)
discard client2.postAvailability(size=0xFFFFF.u256, duration=200.u256, minPrice=300.u256, maxCollateral=300.u256).get
discard client2.postAvailability(size=size, duration=20*60.u256, minPrice=300.u256, maxCollateral=300.u256).get
# client 1 requests storage
let expiry = (await ethProvider.currentTime()) + 30
let cid = client1.upload("some file contents").get
let expiry = (await ethProvider.currentTime()) + 5*60
let cid = client1.upload(data).get
let id = client1.requestStorage(
cid,
duration=duration,
@ -227,10 +224,10 @@ twonodessuite "Integration tests", debug1 = false, debug2 = false:
proofProbability=3.u256,
expiry=expiry,
collateral=200.u256,
nodes = 5,
nodes = nodes,
tolerance = 2).get
check eventually client1.purchaseStateIs(id, "started")
check eventually(client1.purchaseStateIs(id, "started"), timeout=5*60*1000)
let purchase = client1.getPurchase(id).get
check purchase.error == none string
@ -239,7 +236,7 @@ twonodessuite "Integration tests", debug1 = false, debug2 = false:
# only with new transaction
await ethProvider.advanceTime(duration)
check eventually (await token.balanceOf(account2)) - startBalance == duration*reward
check eventually (await token.balanceOf(account2)) - startBalance == duration*reward*nodes.u256
test "request storage fails if nodes and tolerance aren't correct":
let cid = client1.upload("some file contents").get