Skip to content

Commit

Permalink
Fix Shakedex finalize bug, clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kurumiimari committed Jul 1, 2021
1 parent 2bb7471 commit 7ba7803
Show file tree
Hide file tree
Showing 23 changed files with 158 additions and 58 deletions.
9 changes: 6 additions & 3 deletions chain/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,27 @@ const addrBech32 = "hs1qd42hrldu5yqee58se4uj6xctm7nk28r70e84vx"
const addrPubkeyHex = "028d58b6d3c91a1871de5d6292cb435a416f99619b598eb296e9648de15a623fca"

func TestAddress_String(t *testing.T) {
SetCurrNetwork(NetworkMain)
hash, err := hex.DecodeString(addrHashHex)
require.NoError(t, err)
addr := NewAddressFromHash(hash)
require.Equal(t, addrBech32, addr.String(NetworkMain))
require.Equal(t, addrBech32, addr.String())
}

func TestNewAddressFromPubkey(t *testing.T) {
SetCurrNetwork(NetworkMain)
pubB, err := hex.DecodeString(addrPubkeyHex)
require.NoError(t, err)
pub, err := btcec.ParsePubKey(pubB, btcec.S256())
require.NoError(t, err)
addr := NewAddressFromPubkey(pub)
require.NoError(t, err)
require.Equal(t, "hs1qj74uc2cg3le8xslzq73fr78erz42xxnngxztc0", addr.String(NetworkMain))
require.Equal(t, "hs1qj74uc2cg3le8xslzq73fr78erz42xxnngxztc0", addr.String())
}

func TestNewAddressFromBech32(t *testing.T) {
SetCurrNetwork(NetworkMain)
addr, err := NewAddressFromBech32("hs1qj74uc2cg3le8xslzq73fr78erz42xxnngxztc0")
require.NoError(t, err)
require.Equal(t, "hs1qj74uc2cg3le8xslzq73fr78erz42xxnngxztc0", addr.String(NetworkMain))
require.Equal(t, "hs1qj74uc2cg3le8xslzq73fr78erz42xxnngxztc0", addr.String())
}
1 change: 0 additions & 1 deletion chain/covenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ func NewUpdateCovenant(name string, height int, resource *Resource) *Covenant {
}
}


func NewTransferCovenant(name string, height int, transferee *Address) *Covenant {
return &Covenant{
Type: CovenantTransfer,
Expand Down
3 changes: 2 additions & 1 deletion chain/extended_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ func TestMasterExtendedKey(t *testing.T) {

for _, tt := range tests {
t.Run(strings.Replace(tt.path.String(), "/", "-", -1), func(t *testing.T) {
SetCurrNetwork(tt.network)
mk := NewMasterExtendedKeyFromMnemonic(tt.mnemonic, tt.password, tt.network)
derived := DeriveExtendedKey(mk, tt.path...)
require.Equal(t, tt.address, derived.Address().String(tt.network))
require.Equal(t, tt.address, derived.Address().String())
require.Equal(t, tt.xPub, derived.PublicString())
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
"vout": [
{
"value": 2000111800,
"address": {
"version": 0,
"hash": "00bfb1e341bb84a68dd0bc1781c5ece5e5dc3282"
},
"address": "rs1qqzlmrc6phwz2drwshstcr30vuhjacv5zvx599d",
"covenant": {
"type": 0,
"action": "NONE",
Expand Down
6 changes: 6 additions & 0 deletions client/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ func (c *NodeRPCClient) GetNameByHash(hash []byte) (string, error) {
return res, err
}

func (c *NodeRPCClient) GetBloomByHeight(heights []int) ([]*GetBloomRes, error) {
var res []*GetBloomRes
err := c.rpcClient.CallFor(&res, "getbloombyheight", heights)
return res, err
}

func (c *NodeRPCClient) doRestGet(path string, resObj interface{}) error {
return ghttp.DefaultClient.DoGetJSON(
fmt.Sprintf("%s/%s", c.url, path),
Expand Down
9 changes: 9 additions & 0 deletions client/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package client

import "github.com/kurumiimari/gohan/gjson"

type GetBloomRes struct {
Height int `json:"height"`
AddressBloom gjson.ByteString `json:"addressBloom"`
OutpointBloom gjson.ByteString `json:"outpointBloom"`
}
4 changes: 2 additions & 2 deletions cmd/gohan/cmd/dutch_auctions.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ var transferDutchAuctionFill = &cobra.Command{
},
}

var finalizeDutchAuctionFill = &cobra.Command{
var finalizeDutchAuctionFillCmd = &cobra.Command{
Use: "finalize-fill [name] <override-fee-rate-subunits>",
Short: "Finalizes a fill",
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -406,7 +406,7 @@ func init() {
dutchAuctionsCmd.AddCommand(finalizeDutchAuctionListingCmd)
dutchAuctionsCmd.AddCommand(postDutchAuctionListingCmd)
dutchAuctionsCmd.AddCommand(transferDutchAuctionFill)
dutchAuctionsCmd.AddCommand(finalizeDutchAuctionFill)
dutchAuctionsCmd.AddCommand(finalizeDutchAuctionFillCmd)
dutchAuctionsCmd.AddCommand(transferDutchAuctionCancelCmd)
dutchAuctionsCmd.AddCommand(finalizeDutchAuctionCancelCmd)
}
2 changes: 1 addition & 1 deletion cmd/gohan/cmd/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var startCmd = &cobra.Command{
}
}()

return api.Start(tmb, gohan.Config.Network, gohan.Config.Prefix, walletAPIKey, nodeAPIKey)
return api.Start(tmb, gohan.Config.Network, gohan.Config.Prefix, walletAPIKey, nodeAPIKey, nodeURL)
},
}

Expand Down
6 changes: 4 additions & 2 deletions cmd/gohan/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (
var (
prefix string
network string
serverURL string
walletURL string
nodeURL string
)

var cmdLogger = log.ModuleLogger("cmd")
Expand Down Expand Up @@ -45,10 +46,11 @@ var rootCmd = &cobra.Command{
func init() {
rootCmd.PersistentFlags().StringVar(&prefix, "prefix", "~/.gohan", "Sets gohan's data directory")
rootCmd.PersistentFlags().StringVarP(&network, "network", "n", "main", "Set's gohan's network")
rootCmd.PersistentFlags().StringVarP(&serverURL, "server-url", "u", "", "Sets a custom node RPC server url")
rootCmd.PersistentFlags().StringVarP(&walletURL, "wallet-url", "u", "", "Sets a custom node RPC server url")
rootCmd.PersistentFlags().StringVarP(&accountID, "account-id", "a", "default", "Sets the account ID")
rootCmd.PersistentFlags().StringVar(&walletAPIKey, "api-key", "", "Sets the wallet's API key.")
rootCmd.PersistentFlags().StringVar(&nodeAPIKey, "node-api-key", "", "Sets the Handshake full node's API key.")
rootCmd.PersistentFlags().StringVar(&nodeURL, "node-url", "", "Sets an alternate URL to the Handshake full node.")
}

func Execute() {
Expand Down
4 changes: 2 additions & 2 deletions cmd/gohan/cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (

func apiClient() (*api.Client, error) {
var url string
if serverURL == "" {
if walletURL == "" {
url = fmt.Sprintf("http://localhost:%d", gohan.Config.Network.WalletPort)
} else {
url = serverURL
url = walletURL
}

client := api.NewClient(url, walletAPIKey)
Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ module github.com/kurumiimari/gohan
go 1.16

require (
github.com/bits-and-blooms/bloom/v3 v3.0.1
github.com/btcsuite/btcd v0.21.0-beta
github.com/btcsuite/btcutil v1.0.2
github.com/gorilla/mux v1.8.0
github.com/lunixbochs/vtclean v1.0.0 // indirect
github.com/manifoldco/promptui v0.8.0 // indirect
github.com/manifoldco/promptui v0.8.0
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-isatty v0.0.13 // indirect
github.com/mattn/go-sqlite3 v1.14.7
Expand All @@ -19,8 +20,6 @@ require (
github.com/stretchr/testify v1.7.0
github.com/tyler-smith/go-bip32 v1.0.0
github.com/tyler-smith/go-bip39 v1.1.0
github.com/willf/bitset v1.1.11 // indirect
github.com/willf/bloom v2.0.3+incompatible
github.com/ybbus/jsonrpc/v2 v2.1.6
golang.org/x/crypto v0.0.0-20210415154028-4f45737414dc
golang.org/x/net v0.0.0-20210510120150-4163338589ed // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA=
github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
github.com/bits-and-blooms/bloom/v3 v3.0.1 h1:Inlf0YXbgehxVjMPmCGv86iMCKMGPPrPSHtBF5yRHwA=
github.com/bits-and-blooms/bloom/v3 v3.0.1/go.mod h1:MC8muvBzzPOFsrcdND/A7kU7kMhkqb9KI70JlZCP+C8=
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btcd v0.21.0-beta h1:At9hIZdJW0s9E/fAz28nrz6AmcNlSVucCH796ZteX1M=
Expand All @@ -43,9 +47,11 @@ github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cmars/basen v0.0.0-20150613233007-fe3947df716e h1:0XBUw73chJ1VYSsfvcPvVT7auykAJce9FpRr10L6Qhw=
Expand Down Expand Up @@ -234,10 +240,6 @@ github.com/tyler-smith/go-bip32 v1.0.0 h1:sDR9juArbUgX+bO/iblgZnMPeWY1KZMUC2AFUJ
github.com/tyler-smith/go-bip32 v1.0.0/go.mod h1:onot+eHknzV4BVPwrzqY5OoVpyCvnwD7lMawL5aQupE=
github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8=
github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U=
github.com/willf/bitset v1.1.11 h1:N7Z7E9UvjW+sGsEl7k/SJrvY2reP1A07MrGuCjIOjRE=
github.com/willf/bitset v1.1.11/go.mod h1:83CECat5yLh5zVOf4P1ErAgKA5UDvKtgyUABdr3+MjI=
github.com/willf/bloom v2.0.3+incompatible h1:QDacWdqcAUI1MPOwIQZRy9kOR7yxfyEmxX8Wdm2/JPA=
github.com/willf/bloom v2.0.3+incompatible/go.mod h1:MmAltL9pDMNTrvUkxdg0k0q5I0suxmuwp3KbyrZLOZ8=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/ybbus/jsonrpc/v2 v2.1.6 h1:++pboiaaD6TZ9FJ1JOBBRB/tPtR1njYzqz1iSZGv+3Y=
github.com/ybbus/jsonrpc/v2 v2.1.6/go.mod h1:rIuG1+ORoiqocf9xs/v+ecaAVeo3zcZHQgInyKFMeg0=
Expand Down Expand Up @@ -327,8 +329,6 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 h1:RqytpXGR1iVNX7psjB3ff8y7sNFinVFvkx1c8SjBkio=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand Down
4 changes: 2 additions & 2 deletions itest/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func (s *AccountSuite) TestGetAccountInfo() {
info, err := s.client.GetAccount("alice")
require.NoError(t, err)
require.Equal(t, &api.AccountGetRes{
ID: "alice",
Index: 0,
ID: "alice",
Index: 0,
Balances: &walletdb.Balances{
Available: 0,
Immature: 0,
Expand Down
3 changes: 1 addition & 2 deletions itest/dutch_auction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package itest

import (
"github.com/kurumiimari/gohan/chain"
"github.com/kurumiimari/gohan/gjson"
"github.com/kurumiimari/gohan/shakedex"
"github.com/kurumiimari/gohan/wallet/api"
"github.com/kurumiimari/gohan/walletdb"
Expand Down Expand Up @@ -135,7 +134,7 @@ func (s *DutchAuctionSuite) fill() {

_, err := s.client.TransferDutchAuctionFill("bob", &api.TransferDutchAuctionFillReq{
Name: s.name,
LockScriptTxHash: gjson.ByteString(s.auction.LockingOutpoint.Hash),
LockScriptTxHash: s.auction.LockingOutpoint.Hash,
LockScriptOutIdx: s.auction.LockingOutpoint.Index,
PaymentAddress: s.auction.PaymentAddress,
FeeAddress: s.auction.FeeAddress,
Expand Down
2 changes: 1 addition & 1 deletion itest/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func startDaemon(t *testing.T) (*api.Client, func()) {
tmb := new(tomb.Tomb)

tmb.Go(func() error {
return api.Start(tmb, chain.NetworkRegtest, prefix, "", "")
return api.Start(tmb, chain.NetworkRegtest, prefix, "", "", "")
})

cleanup := func() {
Expand Down
5 changes: 3 additions & 2 deletions shakedex/dutch_auction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func TestCreateDutchAuction(t *testing.T) {
t.Parallel()

t.Run("invalid start and end bids", func(t *testing.T) {
_, err := CreateDutchAuction(nil, "foobar", 0, 100, 200, 0, 10, 0, nil, nil, nil)
_, err := CreateDutchAuction(nil, 0, "foobar", 0, 100, 200, 0, 10, 0, nil, nil, nil)
require.Error(t, err)
})

Expand Down Expand Up @@ -193,7 +193,8 @@ func TestCreateDutchAuction(t *testing.T) {
for i, tt := range tests {
t.Run(fmt.Sprintf("%d-%s", i, tt.name), func(t *testing.T) {
auction, err := CreateDutchAuction(
lockCoin,
lockCoin.Prevout,
lockCoin.Value,
"xsqtx",
100,
tt.start,
Expand Down
6 changes: 3 additions & 3 deletions wallet/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ func (a *Account) FinalizeDutchAuction(
}

return a.txTransactor(func(dTx walletdb.Transactor) (*chain.Transaction, error) {
coin, err := walletdb.GetFinalizableDutchAuctionFillCoin(dTx, a.id, name)
coin, recipAddr, err := walletdb.GetFinalizableDutchAuctionFillCoin(dTx, a.id, name)
if errors.Is(err, sql.ErrNoRows) {
return nil, errors.New("you did not win this auction")
}
Expand All @@ -1036,7 +1036,7 @@ func (a *Account) FinalizeDutchAuction(
txb.AddCoin(coin.AsChain())
txb.AddOutput(&chain.Output{
Value: coin.Value,
Address: a.recvMgr.Address(),
Address: recipAddr.Address,
Covenant: chain.NewFinalizeCovenant(
name,
state.Info.Weak,
Expand Down Expand Up @@ -1989,7 +1989,7 @@ func (a *Account) scanIncomingFinalize(q walletdb.Transactor, tx *chain.Transact

var coinType walletdb.CoinType
if txscript.IsHIP1LockingScript(tx.Witnesses[outIdx]) {
coin, err := walletdb.GetCoinByPrevout(q, a.id, input.Prevout)
coin, err := walletdb.GetDutchAuctionCoin(q, a.id, input.Prevout)
if err != nil {
return false, err
}
Expand Down
2 changes: 1 addition & 1 deletion wallet/addr_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package wallet

import (
"bytes"
"github.com/bits-and-blooms/bloom/v3"
"github.com/kurumiimari/gohan/chain"
"github.com/kurumiimari/gohan/txscript"
"github.com/kurumiimari/gohan/walletdb"
"github.com/pkg/errors"
"github.com/willf/bloom"
"os"
"sync"
)
Expand Down
2 changes: 1 addition & 1 deletion wallet/addr_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestAddrManager(t *testing.T) {
chain.HardenNode(chain.NetworkRegtest.KeyPrefix.CoinType),
chain.HardenNode(0),
}...)
ring := NewAccountKeyring(NewEKPrivateKeyer(mk), derived, chain.NetworkRegtest, 0)
ring := NewAccountKeyring(NewEKPrivateKeyer(mk), derived, chain.NetworkRegtest)
dTx := new(dummyTransactor)

tests := []struct {
Expand Down
10 changes: 8 additions & 2 deletions wallet/api/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ import (
"net/http"
)

func Start(tmb *tomb.Tomb, network *chain.Network, prefix, apiKey, nodeAPIKey string) error {
func Start(tmb *tomb.Tomb, network *chain.Network, prefix, apiKey, nodeAPIKey, altNodeURL string) error {
chain.SetCurrNetwork(network)
nodeClient := client.NewNodeClient(fmt.Sprintf("http://localhost:%d", network.NodePort), nodeAPIKey)
var nodeURL string
if altNodeURL == "" {
nodeURL = fmt.Sprintf("http://localhost:%d", network.NodePort)
} else {
nodeURL = altNodeURL
}
nodeClient := client.NewNodeClient(nodeURL, nodeAPIKey)
engine, err := walletdb.NewEngine(prefix)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion wallet/bloom.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package wallet

import (
"bytes"
"github.com/bits-and-blooms/bloom/v3"
"github.com/kurumiimari/gohan/chain"
"github.com/pkg/errors"
"github.com/willf/bloom"
)

// https://hur.st/bloomfilter/?n=1M&p=1.0E-7&m=&k=
Expand Down
26 changes: 26 additions & 0 deletions wallet/bloom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,32 @@ const (
xPub = "xpub6BudTY3ybzN3FC6cLJiYprizHUWMC1UZyK4f7mB6r6DYJPnMT1tRgUtcWzcjBmCrQbJHb1JpbERigfL1a7X2JJsBZVbxXV5PgoDfoUzp43Y"
)

//func TestInterop(t *testing.T) {
// bloom := bloom.New(1678, 23)
// bloom.Add([]byte("test string"))
// bloom.Add([]byte{0x01, 0x02, 0x03})
// bloom.Add(make([]byte, 32, 32))
// buf := new(bytes.Buffer)
// bloom.WriteTo(buf)
// fmt.Println(hex.EncodeToString(buf.Bytes()))
//
// m := murmur3.New128()
// m.Write([]byte("test string"))
// a, b := m.Sum128()
// m.Write([]byte{1})
// c, d := m.Sum128()
// bb := make([]byte, 16)
// binary.BigEndian.PutUint64(bb, a)
// binary.BigEndian.PutUint64(bb[8:], b)
// bi := new(big.Int)
// bi.SetBytes(bb)
// fmt.Println(bi)
// binary.BigEndian.PutUint64(bb, c)
// binary.BigEndian.PutUint64(bb[8:], d)
// bi.SetBytes(bb)
// fmt.Println(bi)
//}

//func TestEstimateParameters(t *testing.T) {
// m, k := bloom.EstimateParameters(100000, 0.000001)
// fmt.Println(m)
Expand Down
Loading

0 comments on commit 7ba7803

Please sign in to comment.