mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.2 KiB
55 lines
1.2 KiB
4 years ago
|
export const tests = []
|
||
|
const t = (f) => tests.push(f)
|
||
|
|
||
|
t(({ eq }) => {
|
||
|
const { chain, ...block } = blockChain({ a: 1 })
|
||
|
return eq(block, {
|
||
|
index: 1,
|
||
|
data: { a: 1 },
|
||
|
prev: { index: 0, hash: '0' },
|
||
|
hash: '1103f27',
|
||
|
})
|
||
|
})
|
||
|
|
||
|
t(({ eq }) => {
|
||
|
const block = blockChain({ a: 1 }).chain({ hello: 'world' })
|
||
|
|
||
|
const chain = block
|
||
|
.chain({ value: 4455 })
|
||
|
.chain({ some: 'data' })
|
||
|
.chain({ cool: 'stuff' })
|
||
|
|
||
|
const fork = block
|
||
|
.chain({ value: 335 })
|
||
|
.chain({ some: 'data' })
|
||
|
.chain({ cool: 'stuff' })
|
||
|
|
||
|
return eq(
|
||
|
{
|
||
|
chainRoot: chain.prev.prev.prev,
|
||
|
forkRoot: chain.prev.prev.prev,
|
||
|
chainHash: chain.hash,
|
||
|
forkHash: fork.hash,
|
||
|
index: chain.index,
|
||
|
data: chain.data,
|
||
|
},
|
||
|
{
|
||
|
chainRoot: block,
|
||
|
forkRoot: block,
|
||
|
chainHash: '1qr3qfs',
|
||
|
forkHash: '1x9gsc1',
|
||
|
index: fork.index,
|
||
|
data: fork.data,
|
||
|
},
|
||
|
)
|
||
|
})
|
||
|
|
||
|
t(({ eq }) => {
|
||
|
const random = Math.random()
|
||
|
const hash = hashCode(`21103f27{"random":${random}}`)
|
||
|
const { prev, chain, ...block } = blockChain({ a: 1 }).chain({ random })
|
||
|
return eq(block, { index: 2, data: { random }, hash })
|
||
|
})
|
||
|
|
||
|
Object.freeze(tests)
|