Adjust values in forum example
- Also add helper function to simplify scenario definition
This commit is contained in:
parent
b7280d9946
commit
1668ceeda3
|
@ -56,100 +56,33 @@
|
|||
expert.addValue('rep', () => bench.reputation.valueOwnedBy(expert.reputationPublicKey));
|
||||
}
|
||||
|
||||
const updateDisplayValuesAndDelay = async (delayMs) => {
|
||||
await delay(delayMs ?? DEFAULT_DELAY_INTERVAL);
|
||||
const addPost = async (author, title, fee, citations = []) => {
|
||||
await scene.startSection();
|
||||
|
||||
const postContent = new PostContent({}).setTitle(title);
|
||||
for (const { postId, weight } of citations) {
|
||||
postContent.addCitation(postId, weight);
|
||||
}
|
||||
|
||||
const { pool, postId } = await author.submitPostWithFee(
|
||||
bench,
|
||||
forum,
|
||||
postContent,
|
||||
{
|
||||
fee,
|
||||
duration: 1000,
|
||||
tokenLossRatio: 1,
|
||||
},
|
||||
);
|
||||
await delay(1000);
|
||||
await pool.evaluateWinningConditions();
|
||||
await scene.endSection();
|
||||
await delay(DEFAULT_DELAY_INTERVAL);
|
||||
return postId;
|
||||
};
|
||||
|
||||
scene.stateToTable('Initial state');
|
||||
|
||||
await updateDisplayValuesAndDelay();
|
||||
|
||||
await scene.startSection();
|
||||
|
||||
const { postId: postId1, pool: pool1 } = await expert1.submitPostWithFee(
|
||||
bench,
|
||||
forum,
|
||||
new PostContent({ hello: 'there' }).setTitle('Post 1'),
|
||||
{
|
||||
fee: 10,
|
||||
duration: 1000,
|
||||
tokenLossRatio: 1,
|
||||
// authorStakeAmount: 10,
|
||||
},
|
||||
);
|
||||
await updateDisplayValuesAndDelay(1000);
|
||||
|
||||
await pool1.evaluateWinningConditions();
|
||||
await updateDisplayValuesAndDelay();
|
||||
|
||||
await scene.endSection();
|
||||
await scene.startSection();
|
||||
|
||||
const { postId: postId2, pool: pool2 } = await expert2.submitPostWithFee(
|
||||
bench,
|
||||
forum,
|
||||
new PostContent({ hello: 'to you as well' })
|
||||
.setTitle('Post 2')
|
||||
.addCitation(postId1, 0.5),
|
||||
{
|
||||
fee: 10,
|
||||
duration: 1000,
|
||||
tokenLossRatio: 1,
|
||||
},
|
||||
);
|
||||
await updateDisplayValuesAndDelay(1000);
|
||||
|
||||
// await expert1.stake(pool2, { position: true, amount 1});
|
||||
// await updateDisplayValuesAndDelay();
|
||||
|
||||
await pool2.evaluateWinningConditions();
|
||||
await updateDisplayValuesAndDelay();
|
||||
|
||||
await scene.endSection();
|
||||
await scene.startSection();
|
||||
|
||||
const { pool: pool3 } = await expert3.submitPostWithFee(
|
||||
bench,
|
||||
forum,
|
||||
new PostContent({ hello: "y'all" })
|
||||
.setTitle('Post 3')
|
||||
.addCitation(postId1, -0.5),
|
||||
{
|
||||
fee: 100,
|
||||
duration: 1000,
|
||||
tokenLossRatio: 1,
|
||||
},
|
||||
);
|
||||
await updateDisplayValuesAndDelay(1000);
|
||||
|
||||
// await expert1.stake(pool3, { position: true, amount 1});
|
||||
// await updateDisplayValuesAndDelay();
|
||||
|
||||
await pool3.evaluateWinningConditions();
|
||||
await updateDisplayValuesAndDelay();
|
||||
|
||||
await scene.endSection();
|
||||
await scene.startSection();
|
||||
|
||||
const { pool: pool4 } = await expert3.submitPostWithFee(
|
||||
bench,
|
||||
forum,
|
||||
new PostContent({ hello: "y'all" })
|
||||
.setTitle('Post 4')
|
||||
.addCitation(postId2, -0.5),
|
||||
{
|
||||
fee: 100,
|
||||
duration: 1000,
|
||||
tokenLossRatio: 1,
|
||||
},
|
||||
);
|
||||
await updateDisplayValuesAndDelay(1000);
|
||||
|
||||
// await expert1.stake(pool3, { position: true, amount 1});
|
||||
// await updateDisplayValuesAndDelay();
|
||||
|
||||
await pool4.evaluateWinningConditions();
|
||||
await updateDisplayValuesAndDelay();
|
||||
|
||||
await scene.endSection();
|
||||
const postId1 = await addPost(expert1, 'Post 1', 20);
|
||||
const postId2 = await addPost(expert2, 'Post 2', 10, [{ postId: postId1, weight: 0.5 }]);
|
||||
await addPost(expert3, 'Post 3', 10, [{ postId: postId1, weight: -1 }]);
|
||||
await addPost(expert3, 'Post 4', 100, [{ postId: postId2, weight: -1 }]);
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue