Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init Testing Chapter #87

Merged
merged 23 commits into from
Dec 1, 2019
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b6908b0
init own testing section
4meta5 Nov 19, 2019
0e15d00
update SUMMARY.md according to proposed reorg
4meta5 Nov 19, 2019
af5b2a0
delete treasury and token sections, start changing smpl-treasury to b…
4meta5 Nov 20, 2019
05856d5
init externalities section
4meta5 Nov 20, 2019
3dbeb80
stash when debugging (considering adding an informal changelog for be…
4meta5 Nov 20, 2019
60c7f4b
update smpl-treasury with more logic
4meta5 Nov 21, 2019
000a72f
add genesis config and test for it
4meta5 Nov 24, 2019
1bea238
set intermediate objectives in the CHANGELOG.md, add more tests to sm…
4meta5 Nov 26, 2019
15904e6
update wording for the changelog
4meta5 Nov 26, 2019
7cd6841
rename schedule_on_finalize to execution_schedule with intention of a…
4meta5 Nov 27, 2019
4cd9c38
trouble compiling execution-schedule
4meta5 Nov 28, 2019
94ec415
fixed up struct-storage, adding tests next
4meta5 Nov 28, 2019
3c2397d
add struct-storage tests and cargo fmt
4meta5 Nov 28, 2019
f7d2393
rewrite code for execution-schedule, next is tests
4meta5 Nov 29, 2019
58fcc74
execution-schedule test scaffolding and one test
4meta5 Nov 29, 2019
404ef47
better test coverage for execution-schedule
4meta5 Nov 29, 2019
eefd2db
delete social-network, add 2/3 of writing for new test chapter
4meta5 Nov 29, 2019
a0bfaeb
fix all rust code block annotations to not allow user to compile and …
4meta5 Nov 30, 2019
f3e9f79
change rust annotations
4meta5 Nov 30, 2019
8aa5da3
master.into()
4meta5 Nov 30, 2019
0c28b3a
attempt to fix build, then ran cargo fmt
4meta5 Nov 30, 2019
3668f74
fix code blocks in instantiable-modules
4meta5 Dec 1, 2019
fb15d2b
fix event initialization instructions in instantiable modules recipe
4meta5 Dec 1, 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
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Version 0.1

**content**
* relative *completion*, but still much room for improvement `=>` the project's intended scope is covered with many basic and a few advanced patterns
* the `kitchen` contains examples of a node, runtimes, and modules
* recent new recipes:
* child-trie storage
* instanceable modules
* execution schedule
* testing section
* in theory, this project should experience diminishing returns, but there is still a high frequency of significant changes and new features

**devops**
* the [book](https://substrate.dev/recipes/) is built and deployed with travis
* #95 consolidates `cargo check` and `cargo test` into one CI workflow handled by Github Actions (mdbook deploy script to be added soon)
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,4 @@ Simple code patterns that demonstrate best practices when building with **[Subst

This book is built with [mdbook](https://rust-lang-nursery.github.io/mdBook/continuous-integration.html) and deployed via [github pages](https://pages.github.com/). The code used to build this book is open source and [open for contributions](./CONTRIBUTING.md).

### Thanks
Thanks to the following for suggestions and content contribution:
* [kaichao](https://github.com/kaichaosun)
* [gautamdhameja](https://github.com/gautamdhameja)
* [joshorndorff](https://github.com/JoshOrndorff)
* [joepetrowski](https://github.com/joepetrowski)
* [ltfschoen](https://github.com/ltfschoen)
* [nczhu](https://github.com/nczhu)
* [riusricardo](https://github.com/riusricardo)
* [shawntabrizi](https://github.com/shawntabrizi)
* [vedant1811](https://github.com/vedant1811)

<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
4 changes: 2 additions & 2 deletions kitchen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ members = [
# "modules/child-tree",
"modules/currency-imbalances",
"modules/double-map",
"modules/execution-schedule",
# "modules/gen-random",
"modules/generic-event",
"modules/hello-substrate",
"modules/linked-map",
"modules/lockable-currency",
"modules/module-constant-config",
"modules/reservable-currency",
"modules/schedule-on-finalize",
"modules/simple-event",
"modules/simple-map",
"modules/single-value",
Expand All @@ -27,7 +27,7 @@ members = [
"modules/default-instance",
# "modules/weights",
"runtimes/super-runtime",
# "runtimes/super-genesis",
"runtimes/super-genesis",
# "runtimes/weight-fee-runtime",
# "runtimes/weight-fee-genesis",
# "node",
Expand Down
2 changes: 1 addition & 1 deletion kitchen/modules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ examples with context
* [Lockable Currency](./lockable-currency)
* [Reservable Currency](./reservable-currency)
* [Simple Treasury](./treasury)
* [On Finalize](./schedule-on-finalize)
* [Execution Schedule](./execution-schedule)

*wip* (see issues for more information)
* [custom origin](./custom-origin)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "schedule-on-finalize"
name = "execution-schedule"
version = "0.1.0"
authors = ["4meta5"]
edition = "2018"
Expand All @@ -10,14 +10,16 @@ std = [
'parity-scale-codec/std',
'support/std',
'system/std',
'balances/std',
'runtime-primitives/std',
]

[dependencies]
rand = "0.7.2"

[dependencies.parity-scale-codec]
default-features = false
features = ['derive']
version = '1.0.6'
version = '1.1.0'

[dependencies.support]
default_features = false
Expand All @@ -31,12 +33,6 @@ git = 'https://github.com/paritytech/substrate.git'
package = 'srml-system'
rev = '6ae3b6c4ddc03d4cdb10bd1d417b95d20f4c1b6e'

[dependencies.balances]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'srml-balances'
rev = '6ae3b6c4ddc03d4cdb10bd1d417b95d20f4c1b6e'

[dependencies.runtime-primitives]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
Expand All @@ -54,3 +50,9 @@ default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'substrate-primitives'
rev = '6ae3b6c4ddc03d4cdb10bd1d417b95d20f4c1b6e'

[dev-dependencies.runtime-io]
default_features = false
git = 'https://github.com/paritytech/substrate.git'
package = 'sr-io'
rev = '6ae3b6c4ddc03d4cdb10bd1d417b95d20f4c1b6e'
51 changes: 51 additions & 0 deletions kitchen/modules/execution-schedule/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Execution Schedule

This module abstracts away the scheduling of task execution and governs the priority of tasks using a council of `AccountId`s stored in runtime storage.

Although we could add more nuanced governance to the `Council`, the purpose of this example is to demonstrate how and when to use `on_initialize` and `on_finalize`.

This example also demonstrates
* generous usage of type aliases
* sorting tasks by priority in `on_finalize`
* signalling priority by council in the runtime (`signal_priority`)
* preparing on-chain state in `on_initialize`
* using a `double_map`
* unit testing with a mock runtime

The context of the example is scheduling the execution of tasks in a queue stored in the runtime. Tasks are structs declared like

```rust
pub struct Task<BlockNumber> {
id: TaskId,
priority_score: PriorityScore,
proposed_at: Timestamp,
expected_execution: BlockNumber,
}
```

# stuck

Right now, it isn't compiling -- I'm getting this error and I believe it's hiding many more errors. I've been refactoring code around it but I need to compile at some point. the path forward might be rewriting it from scratch and incrementally compiling because I tested the syntax used in `balances` for the `VestingSchedule` in `struct-storage` and it worked perfectly.
4meta5 marked this conversation as resolved.
Show resolved Hide resolved

> (I can't isolate the error, but I don't think I need to serde serialize because `balances` doesn't for `VestingScheduler`)

```rust
error[E0463]: can't find crate for `serde`
--> modules/execution-schedule/src/lib.rs:87:1
|
87 | / decl_storage! {
88 | | trait Store for Module<T: Trait> as ExecutionSchedule {
89 | | /// Outstanding tasks getter
90 | | PendingTask get(fn pending_task): map TaskId => Option<Task<T::BlockNumber>>;
... |
111 | | }
112 | | }
| |_^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `execution-schedule`.

To learn more, run the command again with --verbose.
```
Loading