Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
smtmfft committed Oct 29, 2024
1 parent 74b7db0 commit 9a94d80
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 106 deletions.
8 changes: 4 additions & 4 deletions script/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ else
echo "Warning: in debug mode"
fi

TASKDB=${TASKDB:-in-memory}
TASKDB=${TASKDB:-raiko-tasks/in-memory}

if [ -z "${RUN}" ]; then
COMMAND=build
Expand All @@ -49,7 +49,7 @@ fi
# NATIVE
if [ -z "$1" ] || [ "$1" == "native" ]; then
if [ -n "${CLIPPY}" ]; then
cargo clippy -- -D warnings -F $TASKDB
cargo clippy -F ${TASKDB} -- -D warnings
elif [ -z "${RUN}" ]; then
if [ -z "${TEST}" ]; then
echo "Building native prover"
Expand Down Expand Up @@ -128,7 +128,7 @@ if [ "$1" == "risc0" ]; then
cargo ${TOOLCHAIN_RISC0} run ${FLAGS} --features risc0 -F $TASKDB
else
echo "Running Risc0 tests"
cargo ${TOOLCHAIN_RISC0} test ${FLAGS} --lib risc0-driver --features risc0 -- run_unittest_elf -F $TASKDB
cargo ${TOOLCHAIN_RISC0} test ${FLAGS} --lib risc0-driver --features risc0 -F $TASKDB -- run_unittest_elf
cargo ${TOOLCHAIN_RISC0} test ${FLAGS} -p raiko-host -p risc0-driver --features "risc0 enable" -F $TASKDB
fi
fi
Expand Down Expand Up @@ -160,7 +160,7 @@ if [ "$1" == "sp1" ]; then
cargo ${TOOLCHAIN_SP1} run ${FLAGS} --features sp1 -F $TASKDB
else
echo "Running Sp1 unit tests"
cargo ${TOOLCHAIN_SP1} test ${FLAGS} --lib sp1-driver --features sp1 -- run_unittest_elf -F $TASKDB
cargo ${TOOLCHAIN_SP1} test ${FLAGS} --lib sp1-driver --features sp1 -F $TASKDB -- run_unittest_elf
cargo ${TOOLCHAIN_SP1} test ${FLAGS} -p raiko-host -p sp1-driver --features "sp1 enable" -F $TASKDB

# Don't wannt to span Succinct Network and wait 2 hours in CI
Expand Down
150 changes: 48 additions & 102 deletions taskdb/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ mod tests {
.into(),
)
.await
.unwrap();
.unwrap()
.0;
assert_eq!(task_status.len(), 1);
let status = task_status
.first()
Expand All @@ -156,13 +157,6 @@ mod tests {
std::thread::sleep(Duration::from_millis(1));

{
let task_status = tama
.get_task_proving_status(
&(tasks[0].0, tasks[0].1, tasks[0].3, tasks[0].4.to_string()).into(),
)
.await
.unwrap();
println!("{task_status:?}");
let task_0_desc: &TaskDescriptor = &(
tasks[0].0,
tasks[0].2,
Expand All @@ -171,32 +165,38 @@ mod tests {
tasks[0].4.to_string(),
)
.into();
tama.update_task_progress(task_0_desc, TaskStatus::Cancelled_NeverStarted, None)
.await
.unwrap();
let task_status = tama.get_task_proving_status(task_0_desc).await.unwrap().0;
println!("{task_status:?}");
tama.update_task_progress(
task_0_desc.clone(),
TaskStatus::Cancelled_NeverStarted,
None,
)
.await
.unwrap();

let task_status = tama.get_task_proving_status(task_0_desc).await.unwrap();
let task_status = tama.get_task_proving_status(task_0_desc).await.unwrap().0;
println!("{task_status:?}");
assert_eq!(task_status.len(), 2);
assert_eq!(task_status[1].0, TaskStatus::Cancelled_NeverStarted);
assert_eq!(task_status[0].0, TaskStatus::Registered);
}
// -----------------------
{
let task_1_desc = &(
let task_1_desc: &TaskDescriptor = &(
tasks[1].0,
tasks[1].2,
tasks[1].1,
tasks[1].3,
tasks[1].4.to_string(),
)
.into();
tama.update_task_progress(task_1_desc, TaskStatus::WorkInProgress, None)
tama.update_task_progress(task_1_desc.clone(), TaskStatus::WorkInProgress, None)
.await
.unwrap();

{
let task_status = tama.get_task_proving_status(task_1_desc).await.unwrap();
let task_status = tama.get_task_proving_status(task_1_desc).await.unwrap().0;
assert_eq!(task_status.len(), 2);
assert_eq!(task_status[1].0, TaskStatus::WorkInProgress);
assert_eq!(task_status[0].0, TaskStatus::Registered);
Expand All @@ -205,34 +205,15 @@ mod tests {
std::thread::sleep(Duration::from_millis(1));

tama.update_task_progress(
&(
tasks[0].0,
tasks[0].2,
tasks[0].1,
tasks[0].3,
tasks[0].4.to_string(),
)
.into(),
task_1_desc.clone(),
TaskStatus::CancellationInProgress,
None,
)
.await
.unwrap();

{
let task_status = tama
.get_task_proving_status(
&(
tasks[0].0,
tasks[0].2,
tasks[0].1,
tasks[0].3,
tasks[0].4.to_string(),
)
.into(),
)
.await
.unwrap();
let task_status = tama.get_task_proving_status(task_1_desc).await.unwrap().0;
assert_eq!(task_status.len(), 3);
assert_eq!(task_status[2].0, TaskStatus::CancellationInProgress);
assert_eq!(task_status[1].0, TaskStatus::WorkInProgress);
Expand All @@ -241,16 +222,12 @@ mod tests {

std::thread::sleep(Duration::from_millis(1));

tama.update_task_progress(
(tasks[1].0, tasks[1].1, tasks[1].3, tasks[1].4.to_string()).into(),
TaskStatus::Cancelled,
None,
)
.await
.unwrap();
tama.update_task_progress(task_1_desc.clone(), TaskStatus::Cancelled, None)
.await
.unwrap();

{
let task_status = tama.get_task_proving_status(task_1_desc).await.unwrap();
let task_status = tama.get_task_proving_status(task_1_desc).await.unwrap().0;
assert_eq!(task_status.len(), 4);
assert_eq!(task_status[3].0, TaskStatus::Cancelled);
assert_eq!(task_status[2].0, TaskStatus::CancellationInProgress);
Expand All @@ -261,20 +238,20 @@ mod tests {

// -----------------------
{
let task_2_desc = &(
let task_2_desc: &TaskDescriptor = &(
tasks[2].0,
tasks[2].2,
tasks[2].1,
tasks[2].3,
tasks[2].4.to_string(),
)
.into();
tama.update_task_progress(task_2_desc, TaskStatus::WorkInProgress, None)
tama.update_task_progress(task_2_desc.clone(), TaskStatus::WorkInProgress, None)
.await
.unwrap();

{
let task_status = tama.get_task_proving_status(task_2_desc).await.unwrap();
let task_status = tama.get_task_proving_status(task_2_desc).await.unwrap().0;
assert_eq!(task_status.len(), 2);
assert_eq!(task_status[1].0, TaskStatus::WorkInProgress);
assert_eq!(task_status[0].0, TaskStatus::Registered);
Expand All @@ -283,12 +260,12 @@ mod tests {
std::thread::sleep(Duration::from_millis(1));

let proof: Vec<_> = (&mut rng).gen_iter::<u8>().take(128).collect();
tama.update_task_progress(task_2_desc, TaskStatus::Success, Some(&proof))
tama.update_task_progress(task_2_desc.clone(), TaskStatus::Success, Some(&proof))
.await
.unwrap();

{
let task_status = tama.get_task_proving_status(task_2_desc).await.unwrap();
let task_status = tama.get_task_proving_status(task_2_desc).await.unwrap().0;
assert_eq!(task_status.len(), 3);
assert_eq!(task_status[2].0, TaskStatus::Success);
assert_eq!(task_status[1].0, TaskStatus::WorkInProgress);
Expand All @@ -300,43 +277,33 @@ mod tests {

// -----------------------
{
tama.update_task_progress(
(tasks[3].0, tasks[3].1, tasks[3].3, tasks[3].4.to_string()).into(),
TaskStatus::WorkInProgress,
None,
let task_3_desc: &TaskDescriptor = &(
tasks[3].0,
tasks[3].2,
tasks[3].1,
tasks[3].3,
tasks[3].4.to_string(),
)
.await
.unwrap();
.into();
tama.update_task_progress(task_3_desc.clone(), TaskStatus::WorkInProgress, None)
.await
.unwrap();

{
let task_status = tama
.get_task_proving_status(
&(tasks[3].0, tasks[3].1, tasks[3].3, tasks[3].4.to_string()).into(),
)
.await
.unwrap();
let task_status = tama.get_task_proving_status(task_3_desc).await.unwrap().0;
assert_eq!(task_status.len(), 2);
assert_eq!(task_status[1].0, TaskStatus::WorkInProgress);
assert_eq!(task_status[0].0, TaskStatus::Registered);
}

std::thread::sleep(Duration::from_millis(1));

tama.update_task_progress(
(tasks[3].0, tasks[3].1, tasks[3].3, tasks[3].4.to_string()).into(),
TaskStatus::NetworkFailure,
None,
)
.await
.unwrap();
tama.update_task_progress(task_3_desc.clone(), TaskStatus::NetworkFailure, None)
.await
.unwrap();

{
let task_status = tama
.get_task_proving_status(
&(tasks[3].0, tasks[3].1, tasks[3].3, tasks[3].4.to_string()).into(),
)
.await
.unwrap();
let task_status = tama.get_task_proving_status(task_3_desc).await.unwrap().0;
assert_eq!(task_status.len(), 3);
assert_eq!(task_status[2].0, TaskStatus::NetworkFailure);
assert_eq!(task_status[1].0, TaskStatus::WorkInProgress);
Expand All @@ -345,21 +312,12 @@ mod tests {

std::thread::sleep(Duration::from_millis(1));

tama.update_task_progress(
(tasks[3].0, tasks[3].1, tasks[3].3, tasks[3].4.to_string()).into(),
TaskStatus::WorkInProgress,
None,
)
.await
.unwrap();
tama.update_task_progress(task_3_desc.clone(), TaskStatus::WorkInProgress, None)
.await
.unwrap();

{
let task_status = tama
.get_task_proving_status(
&(tasks[3].0, tasks[3].1, tasks[3].3, tasks[3].4.to_string()).into(),
)
.await
.unwrap();
let task_status = tama.get_task_proving_status(task_3_desc).await.unwrap().0;
assert_eq!(task_status.len(), 4);
assert_eq!(task_status[3].0, TaskStatus::WorkInProgress);
assert_eq!(task_status[2].0, TaskStatus::NetworkFailure);
Expand All @@ -371,20 +329,15 @@ mod tests {

let proof: Vec<_> = (&mut rng).gen_iter::<u8>().take(128).collect();
tama.update_task_progress(
(tasks[3].0, tasks[3].1, tasks[3].3, tasks[3].4.to_string()).into(),
task_3_desc.clone(),
TaskStatus::Success,
Some(proof.as_slice()),
)
.await
.unwrap();

{
let task_status = tama
.get_task_proving_status(
&(tasks[3].0, tasks[3].1, tasks[3].3, tasks[3].4.to_string()).into(),
)
.await
.unwrap();
let task_status = tama.get_task_proving_status(task_3_desc).await.unwrap().0;
assert_eq!(task_status.len(), 5);
assert_eq!(task_status[4].0, TaskStatus::Success);
assert_eq!(task_status[3].0, TaskStatus::WorkInProgress);
Expand All @@ -393,14 +346,7 @@ mod tests {
assert_eq!(task_status[0].0, TaskStatus::Registered);
}

assert_eq!(
proof,
tama.get_task_proof(
&(tasks[3].0, tasks[3].1, tasks[3].3, tasks[3].4.to_string()).into()
)
.await
.unwrap()
);
assert_eq!(proof, tama.get_task_proof(task_3_desc,).await.unwrap());
}
}
}

0 comments on commit 9a94d80

Please sign in to comment.