Add tags chapter
This commit is contained in:
@@ -2,6 +2,7 @@ use coracle_lib::events::{
|
||||
Event, EventContent, EventError, EventTemplate, HashedEvent, OwnedEvent, StampedEvent,
|
||||
};
|
||||
use coracle_lib::keys::SecretKey;
|
||||
use coracle_lib::tags::{Tag, Tags};
|
||||
|
||||
fn fixed_secret() -> SecretKey {
|
||||
let bytes: [u8; 32] = [
|
||||
@@ -11,7 +12,7 @@ fn fixed_secret() -> SecretKey {
|
||||
SecretKey::from_hex(&hex::encode(bytes)).unwrap()
|
||||
}
|
||||
|
||||
fn build_hashed(content: &str, tags: Vec<Vec<String>>) -> HashedEvent {
|
||||
fn build_hashed(content: &str, tags: Vec<Tag>) -> HashedEvent {
|
||||
EventContent::new(content, tags)
|
||||
.kind(1)
|
||||
.stamp(1_700_000_000)
|
||||
@@ -21,14 +22,14 @@ fn build_hashed(content: &str, tags: Vec<Vec<String>>) -> HashedEvent {
|
||||
|
||||
fn sign_fixture() -> Event {
|
||||
let sk = fixed_secret();
|
||||
let hashed = build_hashed("hello nostr", vec![vec!["t".into(), "nostr".into()]]);
|
||||
let hashed = build_hashed("hello nostr", vec![Tag::new("t", ["nostr"])]);
|
||||
let sig = sk.sign(&hashed.id);
|
||||
hashed.sign(sig)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pipeline_progresses_through_types() {
|
||||
let content = EventContent::new("hi", vec![]);
|
||||
let content = EventContent::new("hi", Tags::new());
|
||||
let template: EventTemplate = content.kind(1);
|
||||
let stamped: StampedEvent = template.stamp(1_700_000_000);
|
||||
let owned: OwnedEvent = stamped.own(fixed_secret().public_key());
|
||||
|
||||
Reference in New Issue
Block a user