Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

2019 01 24 mem 64 #915

Merged
merged 18 commits into from
Jan 27, 2019
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Changed
- Encoded values in ribosome function's input/output are u64 (up from u32)

### Added
- All structs/values to all HDK functions must implement `Into<JsonString>` and `TryFrom<JsonString>` (derive `DefaultJson` to do this automatically)
- HDK globals `AGENT_ADDRESS`, `AGENT_ID_STR`, `DNA_NAME` and `DNA_ADDRESS` are now set to real, correct values.
Expand Down
90 changes: 45 additions & 45 deletions container_api/src/container/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -853,81 +853,81 @@ pub mod tests {

(func
(export "__hdk_validate_app_entry")
(param $allocation i32)
(result i32)
(param $allocation i64)
(result i64)

(i32.const 0)
(i64.const 0)
)

(func
(export "__hdk_validate_link")
(param $allocation i32)
(result i32)
(param $allocation i64)
(result i64)

(i32.const 0)
(i64.const 0)
)


(func
(export "__hdk_get_validation_package_for_entry_type")
(param $allocation i32)
(result i32)
(param $allocation i64)
(result i64)

;; This writes "Entry" into memory
(i32.store (i32.const 0) (i32.const 34))
(i32.store (i32.const 1) (i32.const 69))
(i32.store (i32.const 2) (i32.const 110))
(i32.store (i32.const 3) (i32.const 116))
(i32.store (i32.const 4) (i32.const 114))
(i32.store (i32.const 5) (i32.const 121))
(i32.store (i32.const 6) (i32.const 34))

(i32.const 7)
(i64.store (i32.const 0) (i64.const 34))
(i64.store (i32.const 1) (i64.const 69))
(i64.store (i32.const 2) (i64.const 110))
(i64.store (i32.const 3) (i64.const 116))
(i64.store (i32.const 4) (i64.const 114))
(i64.store (i32.const 5) (i64.const 121))
(i64.store (i32.const 6) (i64.const 34))

(i64.const 7)
)

(func
(export "__hdk_get_validation_package_for_link")
(param $allocation i32)
(result i32)
(param $allocation i64)
(result i64)

;; This writes "Entry" into memory
(i32.store (i32.const 0) (i32.const 34))
(i32.store (i32.const 1) (i32.const 69))
(i32.store (i32.const 2) (i32.const 110))
(i32.store (i32.const 3) (i32.const 116))
(i32.store (i32.const 4) (i32.const 114))
(i32.store (i32.const 5) (i32.const 121))
(i32.store (i32.const 6) (i32.const 34))

(i32.const 7)
(i64.store (i32.const 0) (i64.const 34))
(i64.store (i32.const 1) (i64.const 69))
(i64.store (i32.const 2) (i64.const 110))
(i64.store (i32.const 3) (i64.const 116))
(i64.store (i32.const 4) (i64.const 114))
(i64.store (i32.const 5) (i64.const 121))
(i64.store (i32.const 6) (i64.const 34))

(i64.const 7)
)

(func
(export "__list_capabilities")
(param $allocation i32)
(result i32)
(param $allocation i64)
(result i64)

(i32.const 0)
(i64.const 0)
)

(func
(export "hello")
(param $allocation i32)
(result i32)
(param $allocation i64)
(result i64)

;; This writes "Holo World" into memory
(i32.store (i32.const 0) (i32.const 72))
(i32.store (i32.const 1) (i32.const 111))
(i32.store (i32.const 2) (i32.const 108))
(i32.store (i32.const 3) (i32.const 111))
(i32.store (i32.const 4) (i32.const 32))
(i32.store (i32.const 5) (i32.const 87))
(i32.store (i32.const 6) (i32.const 111))
(i32.store (i32.const 7) (i32.const 114))
(i32.store (i32.const 8) (i32.const 108))
(i32.store (i32.const 9) (i32.const 100))

(i32.const 10)
(i64.store (i32.const 0) (i64.const 72))
(i64.store (i32.const 1) (i64.const 111))
(i64.store (i32.const 2) (i64.const 108))
(i64.store (i32.const 3) (i64.const 111))
(i64.store (i32.const 4) (i64.const 32))
(i64.store (i32.const 5) (i64.const 87))
(i64.store (i32.const 6) (i64.const 111))
(i64.store (i32.const 7) (i64.const 114))
(i64.store (i32.const 8) (i64.const 108))
(i64.store (i32.const 9) (i64.const 100))

(i64.const 10)
)
)
"#
Expand Down
61 changes: 31 additions & 30 deletions container_api/src/holochain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ mod tests {
r#"
(module
(memory (;0;) 17)
(func (export "genesis") (param $p0 i32) (result i32)
i32.const 9
(func (export "genesis") (param $p0 i64) (result i64)
i64.const 9
)
(data (i32.const 0)
"fail"
Expand All @@ -313,33 +313,34 @@ mod tests {
}

#[test]
#[cfg(feature = "broken-tests")]
fn fails_instantiate_if_genesis_times_out() {
// let dna = create_test_dna_with_wat(
// "test_zome",
// Callback::Genesis.capability().as_str(),
// Some(
// r#"
// (module
// (memory (;0;) 17)
// (func (export "genesis") (param $p0 i32) (result i32)
// (loop (br 0))
// i32.const 0
// )
// (export "memory" (memory 0))
// )
// "#,
// ),
// );
//
// let (context, _test_logger, _) = test_context("bob");
// let result = Holochain::new(dna.clone(), context.clone());
// assert!(result.is_err());
// assert_eq!(
// HolochainInstanceError::from(HolochainError::ErrorGeneric(
// "Timeout while initializing".to_string()
// )),
// result.err().unwrap(),
// );
let dna = create_test_dna_with_wat(
"test_zome",
Callback::Genesis.capability().as_str(),
Some(
r#"
(module
(memory (;0;) 17)
(func (export "genesis") (param $p0 i64) (result i64)
(loop (br 0))
i64.const 0
)
(export "memory" (memory 0))
)
"#,
),
);

let (context, _test_logger, _) = test_context("bob");
let result = Holochain::new(dna.clone(), context.clone());
assert!(result.is_err());
assert_eq!(
HolochainInstanceError::from(HolochainError::ErrorGeneric(
"Timeout while initializing".to_string()
)),
result.err().unwrap(),
);
}

#[test]
Expand Down Expand Up @@ -380,8 +381,8 @@ mod tests {
(memory 1)
(export "memory" (memory 0))
(export "main" (func $func0))
(func $func0 (param $p0 i32) (result i32)
i32.const 16
(func $func0 (param $p0 i64) (result i64)
i64.const 16
)
(data (i32.const 0)
"{\"holo\":\"world\"}"
Expand Down
8 changes: 4 additions & 4 deletions core/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,8 @@ pub mod tests {
r#"
(module
(memory (;0;) 17)
(func (export "genesis") (param $p0 i32) (result i32)
i32.const 0
(func (export "genesis") (param $p0 i64) (result i64)
i64.const 0
)
(data (i32.const 0)
""
Expand Down Expand Up @@ -747,8 +747,8 @@ pub mod tests {
r#"
(module
(memory (;0;) 17)
(func (export "genesis") (param $p0 i32) (result i32)
i32.const 9
(func (export "genesis") (param $p0 i64) (result i64)
i64.const 9
)
(data (i32.const 0)
"1337.0"
Expand Down
Loading