@@ -361,7 +361,19 @@ func clnclnElementsSetup(t *testing.T, fundAmt uint64) (*testframework.BitcoinNo
361361 /// Get PeerSwap plugin path and test dir
362362 _ , filename , _ , _ := runtime .Caller (0 )
363363 pathToPlugin := filepath .Join (filename , ".." , ".." , "out" , "test-builds" , "peerswap" )
364- testDir := t .TempDir ()
364+
365+ // Use os.MkdirTemp() instead of t.TempDir() for the DataDir.
366+ // The shorter temp paths avoid problems with long unix socket paths composed
367+ // using the DataDir.
368+ // See https://github.com/golang/go/issues/62614.
369+ makeDataDir := func () string {
370+ tempDir , err := os .MkdirTemp ("" , "cln-test-" )
371+ require .NoError (t , err , "os.MkdirTemp failed" )
372+ t .Cleanup (func () { os .RemoveAll (tempDir ) })
373+ return tempDir
374+ }
375+
376+ testDir := makeDataDir ()
365377
366378 // Setup nodes (1 bitcoind, 1 liquidd, 2 lightningd)
367379 bitcoind , err := testframework .NewBitcoinNode (testDir , 1 )
@@ -1606,3 +1618,104 @@ func clnclnLWKLiquidSetup(t *testing.T, fundAmt uint64) (*testframework.BitcoinN
16061618
16071619 return bitcoind , liquidd , []* CLightningNodeWithLiquid {{lightningds [0 ]}, {lightningds [1 ]}}, scid , electrsd , lwk
16081620}
1621+
1622+ func clnSingleElementsSetup (t * testing.T , elementsConfig map [string ]string ) (* testframework.BitcoinNode , * testframework.LiquidNode , * testframework.CLightningNode ) {
1623+ _ , filename , _ , _ := runtime .Caller (0 )
1624+ pathToPlugin := filepath .Join (filename , ".." , ".." , "out" , "test-builds" , "peerswap" )
1625+
1626+ makeDataDir := func () string {
1627+ tempDir , err := os .MkdirTemp ("" , "cln-test-" )
1628+ require .NoError (t , err , "os.MkdirTemp failed" )
1629+ t .Cleanup (func () { os .RemoveAll (tempDir ) })
1630+ return tempDir
1631+ }
1632+ testDir := makeDataDir ()
1633+
1634+ bitcoind , err := testframework .NewBitcoinNode (testDir , 1 )
1635+ if err != nil {
1636+ t .Fatalf ("could not create bitcoind: %v" , err )
1637+ }
1638+ t .Cleanup (bitcoind .Kill )
1639+
1640+ err = bitcoind .Run (true )
1641+ if err != nil {
1642+ t .Fatalf ("bitcoind.Run() got err: %v" , err )
1643+ }
1644+
1645+ liquidd , err := testframework .NewLiquidNodeFromConfig (testDir , bitcoind , elementsConfig , 1 )
1646+ if err != nil {
1647+ t .Fatalf ("error creating liquidd node: %v" , err )
1648+ }
1649+ t .Cleanup (liquidd .Kill )
1650+
1651+ err = liquidd .Run (true )
1652+ if err != nil {
1653+ t .Fatalf ("liquidd.Run() got err: %v" , err )
1654+ }
1655+
1656+ lightningd , err := testframework .NewCLightningNode (testDir , bitcoind , 1 )
1657+ if err != nil {
1658+ t .Fatalf ("could not create c-lightning node: %v" , err )
1659+ }
1660+ t .Cleanup (lightningd .Kill )
1661+
1662+ defer printFailedFiltered (t , lightningd .DaemonProcess )
1663+
1664+ err = os .MkdirAll (filepath .Join (lightningd .GetDataDir (), "peerswap" ), os .ModePerm )
1665+ if err != nil {
1666+ t .Fatalf ("could not create dir: %v" , err )
1667+ }
1668+ err = os .WriteFile (
1669+ filepath .Join (lightningd .GetDataDir (), "peerswap" , "policy.conf" ),
1670+ []byte ("accept_all_peers=1\n " ),
1671+ os .ModePerm ,
1672+ )
1673+ if err != nil {
1674+ t .Fatalf ("could not create policy file: %v" , err )
1675+ }
1676+
1677+ walletName := "swap1"
1678+ fileConf := struct {
1679+ Liquid struct {
1680+ RpcUser string
1681+ RpcPassword string
1682+ RpcHost string
1683+ RpcPort uint
1684+ RpcWallet string
1685+ Enabled bool
1686+ }
1687+ }{
1688+ Liquid : struct {
1689+ RpcUser string
1690+ RpcPassword string
1691+ RpcHost string
1692+ RpcPort uint
1693+ RpcWallet string
1694+ Enabled bool
1695+ }{
1696+ RpcUser : liquidd .RpcUser ,
1697+ RpcPassword : liquidd .RpcPassword ,
1698+ RpcHost : "http://127.0.0.1" ,
1699+ RpcPort : uint (liquidd .RpcPort ),
1700+ RpcWallet : walletName ,
1701+ Enabled : true ,
1702+ },
1703+ }
1704+ data , err := toml .Marshal (fileConf )
1705+ require .NoError (t , err )
1706+
1707+ configPath := filepath .Join (lightningd .GetDataDir (), "peerswap" , "peerswap.conf" )
1708+ err = os .WriteFile (configPath , data , os .ModePerm )
1709+ require .NoError (t , err )
1710+
1711+ lightningd .WithCmd ("lightningd" )
1712+
1713+ lightningd .AppendCmdLine ([]string {
1714+ "--dev-bitcoind-poll=1" ,
1715+ "--dev-fast-gossip" ,
1716+ "--large-channels" ,
1717+ fmt .Sprintf ("--plugin=%s" , pathToPlugin ),
1718+ })
1719+
1720+ return bitcoind , liquidd , lightningd
1721+ }
0 commit comments