Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

appleseed-metric

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appleseed-metric - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

LICENSE

2

package.json
{
"name": "appleseed-metric",
"version": "1.0.0",
"version": "1.0.1",
"description": "local trust metric algorithm",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -16,2 +16,3 @@ const test = require("tape")

t.assert(rankings["d"], "node d exists in rankings")
t.false("a" in rankings, "source should not be in rankings")
t.false("x" in rankings, "node x should not be in rankings")

@@ -22,1 +23,54 @@ t.false("y" in rankings, "node y should not be in rankings")

})
test("simple one hop, same weights", (t) => {
const trust = []
const source = "a"
trust.push({ src: 'a', dst: 'b', weight: 0.80 })
trust.push({ src: 'b', dst: 'c', weight: 0.80 })
trust.push({ src: 'b', dst: 'd', weight: 0.80 })
appleseed(source, trust, 200, 0.85, 0.01).then((result) => {
const rankings = result.rankings
const rankB = rankings.b
t.assert(rankB, "node b exists in rankings")
t.assert(rankB > rankings.c, "node b is higher than c")
t.assert(rankB > rankings.d, "node b is higher than d")
t.end()
})
})
test("simple one hop, lower weight", (t) => {
const trust = []
const source = 'a'
trust.push({ src: 'a', dst: 'b', weight: 0.80 })
trust.push({ src: 'b', dst: 'c', weight: 0.80 })
trust.push({ src: 'b', dst: 'd', weight: 0.40 }) // lower
appleseed(source, trust, 200, 0.85, 0.01).then((result) => {
const rankings = result.rankings
const rankB = rankings.b
t.assert(rankB, "node b exists in rankings")
t.assert(rankB > rankings.c, "node b has more energy than c")
t.assert(rankB > rankings.d, "node b has more energy than d")
t.assert(rankings.c > rankings.d, "node c has more energy than d")
t.end()
})
})
test("two trustees", (t) => {
const trust = []
const source = 'a'
// a trusts b and c
trust.push({ src: 'a', dst: 'b', weight: 0.80 })
trust.push({ src: 'a', dst: 'c', weight: 0.80 })
// b trusts d and e
trust.push({ src: 'b', dst: 'd', weight: 0.80 })
trust.push({ src: 'b', dst: 'e', weight: 0.80 })
// c also trusts d
trust.push({ src: 'c', dst: 'd', weight: 0.80 })
appleseed(source, trust, 200, 0.85, 0.01).then((result) => {
const rankings = result.rankings
t.assert(rankings.d > rankings.e, "node d has more energy than e")
t.end()
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc