Adjust values in forum example

- Also add helper function to simplify scenario definition
This commit is contained in:
Ladd Hoffman 2023-01-28 10:55:33 -06:00
parent b7280d9946
commit 1668ceeda3
1 changed files with 27 additions and 94 deletions

View File

@ -56,100 +56,33 @@
expert.addValue('rep', () => bench.reputation.valueOwnedBy(expert.reputationPublicKey)); expert.addValue('rep', () => bench.reputation.valueOwnedBy(expert.reputationPublicKey));
} }
const updateDisplayValuesAndDelay = async (delayMs) => { const addPost = async (author, title, fee, citations = []) => {
await delay(delayMs ?? DEFAULT_DELAY_INTERVAL);
};
scene.stateToTable('Initial state');
await updateDisplayValuesAndDelay();
await scene.startSection(); await scene.startSection();
const { postId: postId1, pool: pool1 } = await expert1.submitPostWithFee( const postContent = new PostContent({}).setTitle(title);
for (const { postId, weight } of citations) {
postContent.addCitation(postId, weight);
}
const { pool, postId } = await author.submitPostWithFee(
bench, bench,
forum, forum,
new PostContent({ hello: 'there' }).setTitle('Post 1'), postContent,
{ {
fee: 10, fee,
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, duration: 1000,
tokenLossRatio: 1, tokenLossRatio: 1,
}, },
); );
await updateDisplayValuesAndDelay(1000); await delay(1000);
await pool.evaluateWinningConditions();
// await expert1.stake(pool3, { position: true, amount 1});
// await updateDisplayValuesAndDelay();
await pool4.evaluateWinningConditions();
await updateDisplayValuesAndDelay();
await scene.endSection(); await scene.endSection();
await delay(DEFAULT_DELAY_INTERVAL);
return postId;
};
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> </script>