Exemple #1
0
func InitializeBalance() {
	var once sync.Once
	onceBody := func() {
		w, err := wallet.NewMapDBWallet()
		if err != nil {
			panic(err)
		}

		fa, err := factom.GetFactoidAddress(FaucetAddressPriv)
		err = w.InsertFCTAddress(fa)
		if err != nil {
			panic(err)
		}

		priv, _, _ := testHelper.NewFactoidAddressStrings(Seed)

		FKey, err = primitives.NewPrivateKeyFromHex(priv)
		if err != nil {
			panic(err)
		}
		ECKey, err = primitives.NewPrivateKeyFromHex(priv)
		if err != nil {
			panic(err)
		}

		FAddressStr, err = factoid.PublicKeyStringToFactoidAddressString(FKey.PublicKeyString())
		if err != nil {
			panic(err)
		}

		ECAddressStr, err = factoid.PublicKeyStringToECAddressString(ECKey.PublicKeyString())
		if err != nil {
			panic(err)
		}

		ECAddress, err = factom.MakeECAddress(ECKey.Key[:32])
		if err != nil {
			panic(err)
		}

		go wsapi.Start(w, fmt.Sprintf(":%d", 8089))
		defer func() {
			time.Sleep(10 * time.Millisecond)
			wsapi.Stop()
		}()

		TopupFAddress()
		TopupECAddress()
	}
	once.Do(onceBody)
}
Exemple #2
0
func TestValidateUserStr(t *testing.T) {
	fctAdd := "FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q"
	fctAddSecret := "Fs3E9gV6DXsYzf7Fqx1fVBQPQXV695eP3k5XbmHEZVRLkMdD9qCK"
	ecAdd := "EC2DKSYyRcNWf7RS963VFYgMExoHRYLHVeCfQ9PGPmNzwrcmgm2r"

	ok := ValidateFUserStr(fctAdd)
	if ok == false {
		t.Errorf("Valid address not validating - %v", fctAdd)
	}

	ok = ValidateECUserStr(ecAdd)
	if ok == false {
		t.Errorf("Valid address not validating - %v", fctAdd)
	}

	ok = ValidateFPrivateUserStr(fctAddSecret)
	if ok == false {
		t.Errorf("Valid address not validating - %v", fctAdd)
	}

	factoidAddresses := []string{}
	//ecAddresses:=[]string{}

	max := 1000

	for i := 0; i < max; i++ {
		_, _, add := testHelper.NewFactoidAddressStrings(uint64(i))
		factoidAddresses = append(factoidAddresses, add)

		//ecAddresses = append(ecAddresses, add)
	}

	for _, v := range factoidAddresses {
		ok := ValidateFUserStr(v)
		if ok == false {
			t.Errorf("Valid address not validating - %v", v)
		}
	}
}