func TestWithdrawals(t *testing.T) { user := GenerateRandomUser() DepositMoneyForUser(user, "BTC", USATOSHI) EnsureBalances(t, user.Id, account.WALLET_MAIN, map[string]int64{ "BTC": SATOSHI, }) // Add a withdrawal to some address. We'll choose the // user's deposit address for this test. address := account.LoadOrCreateDepositAddress(user.Id, account.WALLET_MAIN, "BTC") wth, err := account.AddWithdrawal(user.Id, address, "BTC", USATOSHI) if err != nil { t.Fatal("Unexpected error from AddWithdrawal", err) } // Ensure that the balance for the withdrawal moved to WALLET_RESERVED_WITHDRAWAL// Ensure that the balance for the withdrawal moved to WALLET_RESERVED_WITHDRAWAL EnsureBalances(t, user.Id, account.WALLET_MAIN, map[string]int64{ "BTC": 0, }) EnsureBalances(t, user.Id, account.WALLET_RESERVED_WITHDRAWAL, map[string]int64{ "BTC": SATOSHI, }) // Cancel the withdrawal account.CancelWithdrawal(wth) // Ensure that all the funds moved back to WALLET_MAIN EnsureBalances(t, user.Id, account.WALLET_MAIN, map[string]int64{ "BTC": SATOSHI, }) EnsureBalances(t, user.Id, account.WALLET_RESERVED_WITHDRAWAL, map[string]int64{ "BTC": 0, }) }
func makeTreasury() { treasury.StorePrivateKeyForMPKPubKey("0271b114194fd037a410366b693b338ef7d190c8c2a20ce6164f0c9bc40df417d9", "8b8e225c197e9606e04ae9f0a7582e43177934b7383efbc452055abfbf3a5d0e") // Get the main wallet for testing. user := auth.LoadUserByEmail("*****@*****.**") // Create a withdrawal request. account.AddWithdrawal(user.Id, "12uPSJQ9j3cHPwt2k2JgfkQ4MULwf5cxJH", "BTC", 20000) // Process the withdrawal request. treasury.Process("BTC") }