Esempio n. 1
0
func (s *PtreeSuite) TestInsertRemoveProtection(c *gc.C) {
	root, err := s.ptree.Root()
	// Snapshot original svalues
	origSValues := root.SValues()
	c.Assert(err, gc.IsNil)
	// Add an element, should succeed
	err = s.ptree.Insert(cf.Zs(cf.P_SKS, "224045810486609649306292620830306652473"))
	c.Assert(err, gc.IsNil)
	// Snapshot svalues with one element added
	root, err = s.ptree.Root()
	c.Assert(err, gc.IsNil)
	oneSValues := root.SValues()
	for i, sv := range oneSValues {
		c.Assert(origSValues[i].String(), gc.Not(gc.Equals), sv.String())
	}
	// Attempt to insert duplicate element, should fail
	err = s.ptree.Insert(cf.Zs(cf.P_SKS, "224045810486609649306292620830306652473"))
	c.Assert(err, gc.NotNil)
	// After attempt to insert duplicate, svalues should be unchanged
	root, err = s.ptree.Root()
	c.Assert(err, gc.IsNil)
	oneDupSValues := root.SValues()
	for i, sv := range oneSValues {
		c.Assert(oneDupSValues[i].String(), gc.Equals, sv.String())
	}
	// Remove element, should be back to original svalues
	err = s.ptree.Remove(cf.Zs(cf.P_SKS, "224045810486609649306292620830306652473"))
	c.Assert(err, gc.IsNil)
	root, err = s.ptree.Root()
	c.Assert(err, gc.IsNil)
	rmNotExist := root.SValues()
	for i, sv := range rmNotExist {
		c.Assert(origSValues[i].String(), gc.Equals, sv.String())
	}
	// Remove non-existent element, svalues should be unchanged
	err = s.ptree.Remove(cf.Zs(cf.P_SKS, "224045810486609649306292620830306652473"))
	c.Assert(err, gc.NotNil)
	root, err = s.ptree.Root()
	c.Assert(err, gc.IsNil)
	for i, sv := range root.SValues() {
		c.Assert(origSValues[i].String(), gc.Equals, sv.String())
	}
}
Esempio n. 2
0
func (s *PtreeSuite) TestJustOneKey(c *gc.C) {
	root, err := s.ptree.Root()
	c.Assert(err, gc.IsNil)
	s.ptree.Insert(cf.Zs(cf.P_SKS, "224045810486609649306292620830306652473"))
	expect := cf.NewZSet()
	for _, sv := range []string{
		"306467079064992673198834899522272784866",
		"306467079064992673198834899522272784865",
		"306467079064992673198834899522272784867",
		"306467079064992673198834899522272784864",
		"306467079064992673198834899522272784868",
		"306467079064992673198834899522272784863"} {
		expect.Add(cf.Zs(cf.P_SKS, sv))
	}
	c.Assert(err, gc.IsNil)
	root, err = s.ptree.Root()
	for _, sv := range root.SValues() {
		c.Assert(expect.Has(sv), gc.Equals, true, gc.Commentf("Unexpected svalue: %v", sv))
		expect.Remove(sv)
	}
	c.Assert(expect.Items(), gc.HasLen, 0)
}
Esempio n. 3
0
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Affero General Public License for more details.

   You should have received a copy of the GNU Affero General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package testing

import (
	cf "gopkg.in/hockeypuck/conflux.v2"
)

var PtreeSplits85 = []*cf.Zp{
	cf.Zs(cf.P_SKS, "54945054303302140323349777569652159744"),
	cf.Zs(cf.P_SKS, "301824390735659941098168552847110967299"),
	cf.Zs(cf.P_SKS, "244727299682701342167768131406454086662"),
	cf.Zs(cf.P_SKS, "246090505779456321483693264299682785547"),
	cf.Zs(cf.P_SKS, "132666079786438034357736690869858972940"),
	cf.Zs(cf.P_SKS, "77943753696469936247570506393661277454"),
	cf.Zs(cf.P_SKS, "23196332603806579862361573649796228117"),
	cf.Zs(cf.P_SKS, "4716213446676942567518507102644048922"),
	cf.Zs(cf.P_SKS, "296958268935570641352142910860288566305"),
	cf.Zs(cf.P_SKS, "68302849918166164850536779468406147620"),
	cf.Zs(cf.P_SKS, "218289647857890898753469351137063165732"),
	cf.Zs(cf.P_SKS, "49493891938832871357367248144831830823"),
	cf.Zs(cf.P_SKS, "48291393928127338850139259452183259432"),
	cf.Zs(cf.P_SKS, "86222875303132381523404440898289042729"),
	cf.Zs(cf.P_SKS, "141808492182097342190378424004993438762"),
	cf.Zs(cf.P_SKS, "335945044879925574404988722388729177130"),