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

capabilities-2: separate from zome function declaration #791

Merged
merged 47 commits into from
Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
f954d9e
pre-work for separating capabilities from fn defs
zippy Dec 21, 2018
7fc0f09
merge develop into capabilities-2
zippy Dec 21, 2018
2ee7722
Merge branch 'develop' into capabilities-2
zippy Dec 22, 2018
62da8be
merge branch master
zippy Jan 6, 2019
8b7209d
Merge branch 'develop' into capabilities-2
zippy Jan 8, 2019
2724006
Merge branch 'develop' into capabilities-2
zippy Jan 11, 2019
7616288
Merge branch 'develop' into capabilities-2
zippy Jan 14, 2019
bfc0bbf
merge branch develop into capabilities-2
zippy Jan 16, 2019
e28d2df
Merge branch 'develop' into capabilities-2
zippy Jan 16, 2019
e184f32
now using functions list in zomes as the source of declarations
zippy Jan 16, 2019
e937ef4
rust-fmt
zippy Jan 16, 2019
ac7b230
Merge branch 'develop' into capabilities-2
zippy Jan 16, 2019
d928d19
Merge branch 'develop' into capabilities-2
zippy Jan 17, 2019
b378cd3
removes declarations from Capability, add __list_functions to zome
zippy Jan 17, 2019
3200a82
initial update to mdbook docs for capabilities
zippy Jan 17, 2019
293fe6f
convert functiondeclaration type to vec (was btree)
zippy Jan 17, 2019
a928b0e
add some unit tests for DNA functions
zippy Jan 17, 2019
50a3e16
removed cap name from call
zippy Jan 17, 2019
f212c63
removed cap name from node_js call. and better names for test code
zippy Jan 17, 2019
cbe6aa6
fmt
zippy Jan 17, 2019
a2ddfed
Merge branch 'develop' into capabilities-2
zippy Jan 17, 2019
189fdc7
fixes for broken tests
zippy Jan 17, 2019
c2f8fb7
Merge branch 'develop' into capabilities-2
zippy Jan 18, 2019
3d6e454
remvoed missed cap name in nodejs_container
zippy Jan 18, 2019
7e7d6a2
update define_zome! macro to separate out functions declaration from …
zippy Jan 18, 2019
76328b5
Merge branch 'develop' into capabilities-2
zippy Jan 18, 2019
132756a
updated changelog for capabilities-2
zippy Jan 18, 2019
2112db0
fix type in app_spec capabilities function list
zippy Jan 18, 2019
bbf7d14
merge branch develop into capabilities-2
zippy Jan 18, 2019
5adc3ae
merge branch develop into capabilities-2
zippy Jan 18, 2019
8a3f616
Merge branch 'develop' into capabilities-2
zippy Jan 18, 2019
e5fbbc1
cleanup fn_declarations code into own module and rename Aspect->Trait
zippy Jan 18, 2019
e7cebe7
fixes to c_bindings and some docs which were really out of date
zippy Jan 18, 2019
e806658
Merge branch 'develop' into capabilities-2
zippy Jan 18, 2019
84a839a
fixture fix for c_binding_tests
zippy Jan 19, 2019
c5c1198
Merge branch 'develop' into capabilities-2
zippy Jan 19, 2019
97d73fc
Merge branch 'develop' into capabilities-2
zippy Jan 21, 2019
ade7afb
Merge branch 'develop' into capabilities-2
zippy Jan 23, 2019
016f25f
merge branch develop into capabilities-2
zippy Jan 24, 2019
7c05cbe
removed spuriously added file
zippy Jan 24, 2019
90d7a53
merge branch develop into capabilities-2
zippy Jan 24, 2019
60f4650
Merge branch 'develop' into capabilities-2
Jan 24, 2019
49b1520
remove unusued use
zippy Jan 24, 2019
97739bf
Merge branch 'develop' into capabilities-2
zippy Jan 24, 2019
1b49fb0
fix borked merge
zippy Jan 24, 2019
144068d
updated mdbook docs
zippy Jan 24, 2019
f38938c
Merge branch 'develop' into capabilities-2
zippy Jan 24, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Changed
- Capabilities now separated from function declarations in `define_zome!` and calling zome functions no longer uses capability name parameter [#791](https://github.com/holochain/holochain-rust/pull/779)
### 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
56 changes: 28 additions & 28 deletions app_spec/test/regressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ const scenario = new Scenario([instanceAlice, instanceTash])

scenario.runTape('calling get_links before link_entries makes no difference', async (t, {alice}) => {

const get1 = alice.call("blog", "main", "my_posts", {})
const get1 = alice.call("blog", "my_posts", {})
t.ok(get1.Ok)

const create1 = await alice.callSync("blog", "main", "create_post", {content: 'hi'})
const create1 = await alice.callSync("blog","create_post", {content: 'hi'})
t.ok(create1.Ok)

const get2 = alice.call("blog", "main", "my_posts", {})
const get2 = alice.call("blog", "my_posts", {})
t.ok(get2.Ok)

t.equal(get2.Ok.addresses.length, 1)
Expand All @@ -30,25 +30,25 @@ scenario.runTape('calling get_links twice in a row is no different than calling
// This test is exactly the same as the previous one, but calls my_posts twice in a row.
// This makes the links come through the second time.

const get1 = alice.call("blog", "main", "my_posts", {})
const get1 = alice.call("blog", "my_posts", {})
t.ok(get1.Ok)

const create1 = await alice.callSync("blog", "main", "create_post", {content: 'hi'})
const create1 = await alice.callSync("blog", "create_post", {content: 'hi'})
t.ok(create1.Ok)

alice.call("blog", "main", "my_posts", {})
const get2 = alice.call("blog", "main", "my_posts", {})
alice.call("blog", "my_posts", {})
const get2 = alice.call("blog", "my_posts", {})
t.ok(get2.Ok)

t.equal(get2.Ok.addresses.length, 1)
})

scenario.runTape('not calling get_links in the beginning is also ok', async (t, {alice}) => {

const create1 = await alice.callSync("blog", "main", "create_post", {content: 'hi'})
const create1 = await alice.callSync("blog", "create_post", {content: 'hi'})
t.ok(create1.Ok)

const get1 = alice.call("blog", "main", "my_posts", {})
const get1 = alice.call("blog", "my_posts", {})
t.ok(get1.Ok)

t.equal(get1.Ok.addresses.length, 1)
Expand All @@ -58,21 +58,21 @@ scenario.runTape('alice create & publish post -> recommend own post to self', as

const content = "Holo world...1"
const params = { content: content, in_reply_to: null }
const postResult = await alice.callSync("blog", "main", "create_post", params)
const postResult = await alice.callSync("blog", "create_post", params)
const postAddr = postResult.Ok
t.ok(postAddr, `error: ${postResult}`)

const gotPost = alice.call("blog", "main", "get_post", {post_address: postAddr})
const gotPost = alice.call("blog", "get_post", {post_address: postAddr})
t.ok(gotPost.Ok)
let linked = await alice.callSync('blog', 'main', 'recommend_post', {
post_address: postAddr,

let linked = await alice.callSync('blog', 'recommend_post', {
post_address: postAddr,
agent_address: alice.agentId
})
console.log("linked: ", linked)
t.equal(linked.Ok, null)

const recommendedPosts = alice.call('blog', 'main', 'my_recommended_posts', {})
const recommendedPosts = alice.call('blog', 'my_recommended_posts', {})
console.log("recommendedPosts", recommendedPosts)
console.log('agent addresses: ', alice.agentId, alice.agentId)

Expand All @@ -82,21 +82,21 @@ scenario.runTape('alice create & publish post -> recommend own post to self', as
scenario.runTape('alice create & publish post -> tash recommend to self', async (t, {alice, tash}) => {
const content = "Holo world...2"
const params = { content: content, in_reply_to: null }
const postResult = await alice.callSync("blog", "main", "create_post", params)
const postResult = await alice.callSync("blog", "create_post", params)
const postAddr = postResult.Ok
t.ok(postAddr, `error: ${postResult}`)

const gotPost = tash.call("blog", "main", "get_post", {post_address: postAddr})
const gotPost = tash.call("blog", "get_post", {post_address: postAddr})
t.ok(gotPost.Ok)
let linked = await tash.callSync('blog', 'main', 'recommend_post', {
post_address: postAddr,

let linked = await tash.callSync('blog', 'recommend_post', {
post_address: postAddr,
agent_address: tash.agentId
})
console.log("linked: ", linked)
t.equal(linked.Ok, null)

const recommendedPosts = tash.call('blog', 'main', 'my_recommended_posts', {})
const recommendedPosts = tash.call("blog", "my_recommended_posts", {})
console.log("recommendedPosts", recommendedPosts)
console.log('agent addresses: ', alice.agentId, tash.agentId)

Expand All @@ -106,21 +106,21 @@ scenario.runTape('alice create & publish post -> tash recommend to self', async
scenario.runTape('create & publish post -> recommend to other agent', async (t, {alice, tash}) => {
const content = "Holo world...3"
const params = { content: content, in_reply_to: null }
const postResult = await alice.callSync("blog", "main", "create_post", params)
const postResult = await alice.callSync("blog", "create_post", params)
const postAddr = postResult.Ok
t.ok(postAddr, `error: ${postResult}`)

const gotPost = tash.call("blog", "main", "get_post", {post_address: postAddr})
const gotPost = tash.call("blog", "get_post", {post_address: postAddr})
t.ok(gotPost.Ok)
let linked = await alice.callSync('blog', 'main', 'recommend_post', {
post_address: postAddr,

let linked = await alice.callSync('blog', 'recommend_post', {
post_address: postAddr,
agent_address: tash.agentId
})
console.log("linked: ", linked)
t.equal(linked.Ok, null)
const recommendedPosts = tash.call('blog', 'main', 'my_recommended_posts', {})

const recommendedPosts = tash.call('blog', 'my_recommended_posts', {})
console.log("recommendedPosts", recommendedPosts)
console.log('agent addresses: ', alice.agentId, tash.agentId)

Expand Down
30 changes: 15 additions & 15 deletions app_spec/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ scenario1.runTape('call', async (t, { alice }) => {
const num1 = 2
const num2 = 2
const params = { num1, num2 }
const result = alice.call("blog", "main", "check_sum", params)
const result = alice.call("blog", "check_sum", params)

t.equal(result.Ok, 4)
})

scenario1.runTape('hash_post', async (t, { alice }) => {

const params = { content: "Holo world" }
const result = alice.call("blog", "main", "post_address", params)
const result = alice.call("blog", "post_address", params)

t.equal(result.Ok, "QmY6MfiuhHnQ1kg7RwNZJNUQhwDxTFL45AAPnpJMNPEoxk")
})
Expand All @@ -50,7 +50,7 @@ scenario1.runTape('create_post', async (t, { alice }) => {
const content = "Holo world"
const in_reply_to = null
const params = { content, in_reply_to }
const result = alice.call("blog", "main", "create_post", params)
const result = alice.call("blog", "create_post", params)

t.ok(result.Ok)
t.notOk(result.Err)
Expand All @@ -62,7 +62,7 @@ scenario1.runTape('create_post with bad reply to', async (t, { alice }) => {
const content = "Holo world"
const in_reply_to = "bad"
const params = { content, in_reply_to }
const result = alice.call("blog", "main", "create_post", params)
const result = alice.call("blog", "create_post", params)

// bad in_reply_to is an error condition
t.ok(result.Err)
Expand All @@ -78,7 +78,7 @@ scenario1.runTape('post max content size 280 characters', async (t, { alice }) =
const content = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
const in_reply_to = null
const params = { content, in_reply_to }
const result = alice.call("blog", "main", "create_post", params)
const result = alice.call("blog", "create_post", params)

// result should be an error
t.ok(result.Err);
Expand All @@ -96,22 +96,22 @@ scenario1.runTape('posts_by_agent', async (t, { alice }) => {
const agent = "Bob"
const params = { agent }

const result = alice.call("blog", "main", "posts_by_agent", params)
const result = alice.call("blog", "posts_by_agent", params)

t.deepEqual(result.Ok, { "addresses": [] })
})

scenario1.runTape('my_posts', async (t, { alice }) => {

await alice.callSync("blog", "main", "create_post",
await alice.callSync("blog", "create_post",
{ "content": "Holo world", "in_reply_to": "" }
)

await alice.callSync("blog", "main", "create_post",
await alice.callSync("blog", "create_post",
{ "content": "Another post", "in_reply_to": "" }
)

const result = alice.call("blog", "main", "my_posts", {})
const result = alice.call("blog", "my_posts", {})

t.equal(result.Ok.addresses.length, 2)
})
Expand All @@ -135,11 +135,11 @@ scenario1.runTape('create/get_post roundtrip', async (t, { alice }) => {
const content = "Holo world"
const in_reply_to = null
const params = { content, in_reply_to }
const create_post_result = alice.call("blog", "main", "create_post", params)
const create_post_result = alice.call("blog", "create_post", params)
const post_address = create_post_result.Ok

const params_get = { post_address }
const result = alice.call("blog", "main", "get_post", params_get)
const result = alice.call("blog", "get_post", params_get)

const entry_value = JSON.parse(result.Ok.App[1])
t.comment("get_post() entry_value = " + entry_value + "")
Expand All @@ -152,7 +152,7 @@ scenario1.runTape('get_post with non-existant address returns null', async (t, {

const post_address = "RANDOM"
const params_get = { post_address }
const result = alice.call("blog", "main", "get_post", params_get)
const result = alice.call("blog", "get_post", params_get)

// should be Ok value but null
// lookup did not error
Expand All @@ -165,18 +165,18 @@ scenario2.runTape('scenario test create & publish post -> get from other instanc

const initialContent = "Holo world"
const params = { content: initialContent, in_reply_to: null }
const create_result = await alice.callSync("blog", "main", "create_post", params)
const create_result = await alice.callSync("blog", "create_post", params)

const params2 = { content: "post 2", in_reply_to: null }
const create_result2 = await bob.callSync("blog", "main", "create_post", params2)
const create_result2 = await bob.callSync("blog", "create_post", params2)

t.equal(create_result.Ok.length, 46)
t.equal(create_result.Ok, "QmY6MfiuhHnQ1kg7RwNZJNUQhwDxTFL45AAPnpJMNPEoxk")

const post_address = create_result.Ok
const params_get = { post_address }

const result = bob.call("blog", "main", "get_post", params_get)
const result = bob.call("blog", "get_post", params_get)
const value = JSON.parse(result.Ok.App[1])
t.equal(value.content, initialContent)
})
1 change: 0 additions & 1 deletion app_spec/zomes/blog/code/src/blog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ pub fn handle_check_sum(num1: u32, num2: u32) -> ZomeApiResult<JsonString> {
hdk::call(
hdk::THIS_INSTANCE,
"summer",
"main",
"test_token",
"sum",
check_sum_args(num1, num2).into(),
Expand Down
Loading