<commit_before>package actor

import (
	"testing"

	"github.com/AsynkronIT/protoactor-go/eventstream"
	"github.com/stretchr/testify/assert"
)

func TestDeadLetterAfterStop(t *testing.T) {
	actor := Spawn(FromProducer(NewBlackHoleActor))
	done := false
	sub := eventstream.Subscribe(func(msg interface{}) {
		if deadLetter, ok := msg.(*DeadLetterEvent); ok {
			if deadLetter.PID == actor {
				done = true
			}
		}
	})
	defer eventstream.Unsubscribe(sub)

	actor.
		StopFuture().
		Wait()

	actor.Tell("hello")

	assert.True(t, done)
}

func TestDeadLetterWatchRespondsWithTerminate(t *testing.T) {
	//create an actor
	pid := Spawn(FromProducer(NewBlackHoleActor))
	//stop id
	pid.StopFuture().Wait()
	f := NewFuture(testTimeout)
	//send a watch message, from our future
	pid.sendSystemMessage(&Watch{Watcher: f.PID()})
	f.Wait()
}
<commit_msg>added failure cond to deadletter watch test<commit_after>package actor

import (
	"testing"

	"github.com/AsynkronIT/protoactor-go/eventstream"
	"github.com/stretchr/testify/assert"
)

func TestDeadLetterAfterStop(t *testing.T) {
	actor := Spawn(FromProducer(NewBlackHoleActor))
	done := false
	sub := eventstream.Subscribe(func(msg interface{}) {
		if deadLetter, ok := msg.(*DeadLetterEvent); ok {
			if deadLetter.PID == actor {
				done = true
			}
		}
	})
	defer eventstream.Unsubscribe(sub)

	actor.
		StopFuture().
		Wait()

	actor.Tell("hello")

	assert.True(t, done)
}

func TestDeadLetterWatchRespondsWithTerminate(t *testing.T) {
	//create an actor
	pid := Spawn(FromProducer(NewBlackHoleActor))
	//stop id
	pid.StopFuture().Wait()
	f := NewFuture(testTimeout)
	//send a watch message, from our future
	pid.sendSystemMessage(&Watch{Watcher: f.PID()})
	err := f.Wait()
	if err != nil {
		t.Fail()
	}
}

{'fraction_non_alphanumeric': 0.1429384965831435, 'fraction_numerical': 0.0, 'mean_word_length': 4.439628482972136, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5751598', 'n_tokens_mistral': 675, 'n_tokens_neox': 629, 'n_words': 125}