-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wasm): Wasm Integration Tests working in CI (#197)
* fix(wasm): Fix running wasm integration tests * fix(wasm): Make logging work inside the wasm integration tests * feat(wasm): working hashing integration test * ci(wasm): align rust builds with cat-ci latest version * feat(wasm): Add crypto wasm integration tests * fix(hermes): Re-enable hermes full build after getting wasm integration tests working * fix(wasm): silence the initial print inside wasm integration tests to prevent issues when running * fix(wasm): remove unused import after silencing the wasm integration tester * style(hermes): Fix code format * fix(spelling): spelling issue * fix(cbork): Align deny,toml with CI * fix(wasm): Align deny.toml with CI * Update hermes/bin/src/runtime_extensions/hermes/crypto/host.rs Co-authored-by: bkioshn <[email protected]> * Update hermes/bin/src/runtime_extensions/hermes/crypto/host.rs Co-authored-by: bkioshn <[email protected]> * feat: hermes-cron integration test cases (#199) * feat(wip): stub hermes-cron integration test cases * feat: add tests for cron api functions * fix: compare returned string with expected * feat(warm): Add Cardano Runtime Extension integration test skeleton (#198) * feat(wasm): Add Cardano Runtime Extension integration tests skeleton * feat(wasm): Use pallas to parse blocks in Cardano RTE integration test component --------- Co-authored-by: Steven Johnson <[email protected]> * fix(wasm): remove commented obsolete code * Update wasm/integration-test/crypto/crypto.c Co-authored-by: bkioshn <[email protected]> * test: time module (#200) * feat: initial commit * feat: simple function * ci: add test * test: restructure and add test to localtime * fix: minor format * refactor: remove localtime name * fix: localtime issue * feat: clocks test * fix: test warms * fix: use existing tests * chore: earthfile tmp * fix: builder * fix: remove wall test * chore: fmtfix * fix(spelling): add to project words * fix(wasm): remove generated bindings, try and use autogenerated ones * chore(wasm): Fix Cardano RTE wasm integration test module (#204) * fix(hermes): Update rust builders to the latest --------- Co-authored-by: bkioshn <[email protected]> Co-authored-by: Joaquín Rosales <[email protected]> Co-authored-by: Felipe Rosa <[email protected]> Co-authored-by: Apisit Ritreungroj <[email protected]>
- Loading branch information
1 parent
5a814ce
commit 7f662dd
Showing
39 changed files
with
1,758 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ bmac | |
BROTLI | ||
CHAINCODE | ||
cardano | ||
cdylib | ||
chaincode | ||
cbor | ||
CBOR | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
hermes/bin/src/runtime_extensions/hermes/localtime/time.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
//! Localtime host implementation for WASM runtime. | ||
use chrono::{Local, TimeZone}; | ||
use chrono_tz::Tz; | ||
|
||
use crate::runtime_extensions::{ | ||
bindings::{ | ||
hermes::localtime::api::{Errno, Localtime, Timezone}, | ||
wasi::clocks::wall_clock::Datetime, | ||
}, | ||
hermes::localtime::get_tz, | ||
}; | ||
|
||
/// (Implementation) Get localtime from a datetime or now. | ||
pub(super) fn get_localtime( | ||
when: Option<Datetime>, tz: Option<Timezone>, | ||
) -> Result<Localtime, Errno> { | ||
let timezone = get_tz(tz)?; | ||
let local_naive = match when { | ||
Some(Datetime { | ||
seconds, | ||
nanoseconds, | ||
}) => { | ||
let seconds = seconds.try_into().map_err(|_| Errno::InvalidLocaltime)?; | ||
let utc_dt = chrono::DateTime::from_timestamp(seconds, nanoseconds) | ||
.ok_or(Errno::InvalidLocaltime)?; | ||
utc_dt.naive_utc() | ||
}, | ||
None => Local::now().naive_utc(), | ||
}; | ||
let local_date_time = timezone.from_utc_datetime(&local_naive); | ||
|
||
local_date_time.try_into() | ||
} | ||
|
||
/// (Implementation) Get a new localtime from a localtime, by recalculating time for a new | ||
/// timezone. | ||
pub(super) fn alt_localtime(time: Localtime, tz: Option<Timezone>) -> Result<Localtime, Errno> { | ||
let local_date_time: chrono::DateTime<Tz> = time.try_into()?; | ||
let alt_local_date_time = match tz { | ||
Some(alt_tz) => { | ||
let tz = get_tz(Some(alt_tz))?; | ||
tz.from_utc_datetime(&local_date_time.naive_utc()) | ||
}, | ||
None => local_date_time, | ||
}; | ||
|
||
alt_local_date_time.try_into() | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_get_localtime_with_utc_offset() { | ||
let result = get_localtime(None, Some(String::from("Europe/London"))); | ||
assert!(result.is_ok()); // Check if the function call was successful | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.