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

fix: anchor after each write #167

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions hermetic/src/cli/tester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@ fn job_init() -> Container {
Container {
name: "init-tests".to_owned(),
image: Some("stedolan/jq".to_owned()),
image_pull_policy: Some("IfNotPresent".to_owned()),
command: Some(vec![
"/bin/bash".to_owned(),
"-c".to_owned(),
Expand Down
2 changes: 1 addition & 1 deletion suite/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ RUN pnpm install
COPY src/ ./src

# Select all tests by default
ENV TEST_SELECTOR "correctness"
ENV TEST_SELECTOR="correctness"

ENTRYPOINT ["/app/entrypoint.sh", "run", "test", "--testPathPattern", "$TEST_SELECTOR"]
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ describe('Ceramic<->CAS basic integration', () => {

// Test document creation is anchored correctly
console.log('Waiting for anchor of genesis record')
await waitForAnchor(doc).catch((errStr) => {
throw new Error(errStr)
})
await waitForAnchor(doc)
expect(doc.state.log.length).toEqual(2)

// Test document update
Expand All @@ -50,14 +48,12 @@ describe('Ceramic<->CAS basic integration', () => {

// Test document update is anchored correctly
console.log('Waiting for anchor of update')
await waitForAnchor(doc).catch((errStr) => {
throw new Error(errStr)
})
await waitForAnchor(doc)
expect(doc.content).toEqual(newContent)
expect(doc.state.log.length).toEqual(4)
})

test('multiple documents are anchored properly, multiple updates per anchor batch', async () => {
test('multiple documents are anchored properly', async () => {
const content0 = { step: 0 }
const content1 = { step: 1 }
const content2 = { step: 2 }
Expand All @@ -78,18 +74,10 @@ describe('Ceramic<->CAS basic integration', () => {

// Test document creation is anchored correctly
console.log('Waiting for anchor of genesis records')
await waitForAnchor(doc1).catch((errStr) => {
throw new Error(errStr)
})
await waitForAnchor(doc2).catch((errStr) => {
throw new Error(errStr)
})
await waitForAnchor(doc3).catch((errStr) => {
throw new Error(errStr)
})
await waitForAnchor(doc4).catch((errStr) => {
throw new Error(errStr)
})
await waitForAnchor(doc1)
await waitForAnchor(doc2)
await waitForAnchor(doc3)
await waitForAnchor(doc4)

expect(doc1.state.anchorStatus).toEqual(AnchorStatus.ANCHORED)
expect(doc1.state.log.length).toEqual(2)
Expand All @@ -101,52 +89,36 @@ describe('Ceramic<->CAS basic integration', () => {
expect(doc4.state.log.length).toEqual(2)

// Test document updates
// The anchor option is no longer honored when ceramic-one does the anchroing.
console.log('Updating documents')
await doc1.replace(content1, undefined, { anchor: true })
await doc2.replace(content1, undefined, { anchor: false })
await doc3.replace(content1, undefined, { anchor: false })
await doc4.replace(content1, undefined, { anchor: false })
await doc1.replace(content1)
await doc2.replace(content2)
await doc3.replace(content3)
await doc4.replace(content4)

await doc2.replace(content2, undefined, { anchor: true })
await doc3.replace(content2, undefined, { anchor: false })
await doc4.replace(content2, undefined, { anchor: false })
// Test document updates are anchored correctly
console.log('Waiting for anchor of updates')

await doc3.replace(content3, undefined, { anchor: true })
await doc4.replace(content3, undefined, { anchor: false })
await waitForAnchor(doc1)
await waitForAnchor(doc2)
await waitForAnchor(doc3)
await waitForAnchor(doc4)

await doc4.replace(content4, undefined, { anchor: true })

expect(doc1.content).toEqual(content1)
expect(doc2.content).toEqual(content2)
expect(doc3.content).toEqual(content3)
expect(doc4.content).toEqual(content4)

// Test document updates are anchored correctly
console.log('Waiting for anchor of updates')
await waitForAnchor(doc1).catch((errStr) => {
throw new Error(errStr)
})
await waitForAnchor(doc2).catch((errStr) => {
throw new Error(errStr)
})
await waitForAnchor(doc3).catch((errStr) => {
throw new Error(errStr)
})
await waitForAnchor(doc4).catch((errStr) => {
throw new Error(errStr)
})

expect(doc1.state.anchorStatus).toEqual(AnchorStatus.ANCHORED)
expect(doc2.state.anchorStatus).toEqual(AnchorStatus.ANCHORED)
expect(doc3.state.anchorStatus).toEqual(AnchorStatus.ANCHORED)
expect(doc4.state.anchorStatus).toEqual(AnchorStatus.ANCHORED)
expect(doc1.content).toEqual(content1)
expect(doc2.content).toEqual(content2)
expect(doc3.content).toEqual(content3)
expect(doc4.content).toEqual(content4)

expect(doc1.state.log.length).toEqual(4)
expect(doc2.state.log.length).toEqual(5)
expect(doc3.state.log.length).toEqual(6)
expect(doc4.state.log.length).toEqual(7)
expect(doc2.state.log.length).toEqual(4)
expect(doc3.state.log.length).toEqual(4)
expect(doc4.state.log.length).toEqual(4)
})
})
Loading